jquery plugin function test
this is a step through for a test jquery plugin
by nickadeemus2002
February 15, 2013
HTML
<div class="get-this">
<p>Turn me red with your plugin..</p>
</div>
<div class="get-this">
<p>me 2..</p>
</div>
<div class="get-this">
<p>and me three..</p>
</div>
CSS
.red{color:#fff; background-color:#ff0000;border:1px solid #f2f2f2;}
.give-me-room{margin:10px;padding:5px;}
JavaScript
(function($){
$.fn.doThis = function(){
/**
* this:
* - all elements in selector
* - context
* - length property
* - prevObject
* - selector
*
**/
return this.each(function(){
$(this).addClass('red').addClass('give-me-room');
});
};
})(jQuery);
$(document).ready(function() {
$('.get-this').doThis();
});