Skip to content

Instantly share code, notes, and snippets.

@hitecherik-gist
Created December 4, 2012 21:19
Show Gist options
  • Save hitecherik-gist/4208794 to your computer and use it in GitHub Desktop.
Save hitecherik-gist/4208794 to your computer and use it in GitHub Desktop.
JS: jQuery Plugin
<!--
Created by Alexander Nielsen. alex@hitecherik.site11.com
-->
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="Alexander Nielsen" />
<title>Testing plugin...</title>
</head>
<body>
<h1>Testing plugin...</h1>
<!--body content here-->
<!-- end html start scripts -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.js"></script>
<script type="text/javascript" src="../test-plugin.js"></script>
<script type="text/javascript">
$('h1').alertMeAboutSomething('Hello! This is a jQuery alert!');
</script>
</body>
</html>
(function( $ ){
$.fn.maxHeight = function() {
var max = 0;
this.each(function() {
max = Math.max( max, $(this).height() );
});
return max;
};
$.fn.alertMeAboutSomething = function(alertMessage) {
alert(alertMessage);
}
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment