Wednesday, July 18, 2012

Common jquery shortcut

$(...)
=>
jQuery()

All jquery methods are started by calling jQuery(), which can be written as $(...)
 


$(function(){...});
=> 
$(document).ready(function(){...});
The function will be called when document is ready.
Do not mix this shortcut with javascript self-invoked anonymous function, the ending () makes the js function to be invoked, and thbe leading () indicates this is not normal function.
(function(){
...
})();
 

$.fn.myFeature = function () { ... } 
=>
jQuery.prototype.myFeature = function () { ... } 
 
The function to create a jquery plugin by adding method into p


No comments:

Post a Comment