jQuery create a simple plugin
Posted 11 August, 2008on:
- In: Tutorials
- Comments Off on jQuery create a simple plugin
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
// here we can access any properties using
// the normal jQuery selectors
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:
Another example of how easy and powerful jQuery is 🙂 Look here for more information.