jQuery and jQuery UI > Document Ready Function |
To prevent jQuery code from running before the document is completely loaded, all jQuery functions should be placed within the $(document).ready function
. For example:
$(document).ready(function(){
// Do something on document ready.
});
If you prefer, you can use a shortened version of the $(document).ready
function instead. For example:
$(function() {
// do something on document ready
});
All scripts residing inside of the $(document).ready
function will load as soon as the DOM is loaded and before the page contents are loaded.