Launching a jQuery script
Most of the time you'll want your script to launch and/or be available as soon as the DOM is loaded and ready. For this, you can use the standard "on document ready" technique as follows:
jQuery(document).ready(function(){
// Your jQuery script go here
});
You can reduce the previous code, just a bit, by using the following code:
jQuery(function(){
// Your jQuery script go here
});
If the jQuery
variable is evoked and a function immediately passed, jQuery assumes the .ready
event is implied and will run the next selection and function as soon as the DOM is loaded.