This is just a quick tutorial (more of a code snippet) for creating a very simple plugin for jQuery.
Of course, there are lots of tutorials around for this, this is mainly for reference
$.fn.myFunction = function()
{
// use the following loop to iterate through all objects
// returned by the jQuery selector which was used
return this.each(function()
{
// here we can access any properties using
// the normal jQuery selectors
alert($(this).html());
$(this).addClass('red');
});
};
So this function alerts the HTML of the selected element(s) and adds a new class ‘red’. You can then call the new function using:
$('#myElement').myFunction();
Another example of how easy and powerful jQuery is
Look here for more information.