JQuery Functions

What is the use of writing a jQuery function, for example ...

$(function myFunction() { ... }); 

What I mean is that wrap the function in $

+8
function jquery
source share
3 answers

I think you mean like this:

 $(function() { ... }); 

This is a shorthand for:

 $(document).ready(function() { ... }); 

What he does is register a handler for the ready event, so the code in the function will be launched immediately after loading the document.

+12
source share

This is a shortcut for

 $(document).ready(function myFunction() { ... }); 

See http://api.jquery.com/ready/

+3
source share

This is actually a short hand for the following syntax:

 function handleDocumentReady () { // handleDocumentReady () // Code to handle initialization goes here... } // handleDocumentReady () $(document).ready (handleDocumentReady); 
+1
source share

All Articles