Your First jQuery Plugin

Posted Jul 29, 2009 // 0 comments
Irakli:

We all have come to love and admire jQuery for the amazing Javascript library it is. But we also have fallen in love with numerous extensions to jQuery; plugins, modules - whatever you call 'em. Most of us, however, just use these goodies and bless the hearts of all wonderful people who make the gems available. Some of us are even a little bit intimidated when we look at all the complicated Javascript-ing going on in the source files... Especially when/if we accidentally look into a minified version ;) Jokes aside, starting a new jQuery plugin is quite simple. Here is just how easy one could be:

(function($) {

// jQuery plugin initialization

$.fn.irakli = function(conf) {

alert("okaaaay");

}; })(jQuery);

This goofy plugin will allow you to invoke irakli() function on a jQuery object. For instance, $('div.something').irakli() will have an alert box pop up.

About Irakli

Irakli is Director of Product Development at Phase2 Technology. His main responsibility is development of packaged, turn-key solutions using open-source technologies and cutting-edge semantic APIs.

Irakli has been an avid open-source ...

more >

Read Irakli's Blog

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <a> <strong> <code> <p> <img> <ul> <ol> <li> <h2> <h3> <h4> <b> <u> <i>
  • You may insert videos with [video:URL]

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.