Post your trick

What is (function($){…})(jquery) ??

All jQuery plugins code is wrapped in this anonymous function.So what exactly this function do ??
Well,my little research shows that this allows the use of $ within this function without conflicting with other JavaScript libraries who are using it. Basically, since we are setting $ as a parameter, $ will overwrite any globally defined variables/references of $ in that particular anonymous function.

// Assume “$” is a prototype reference
(function ($) {
// Here “$” is a jQuery reference
})(jQuery)


Leave a Reply

     

     

     

Post A Trick !

How does "Kodetricks" work?

We at kodeplay like to share knowledge. With Kodetricks, even you can join us. All you need to do is post a programming related trick if you have one or rate a trick if you like someone else's.



Technology

Contact Us