jquery wait for page to load code example
Example 1: jquery document ready
The .ready() method is typically used with an anonymous function:
$( document ).ready(function() {
});
Which is equivalent to the recommended way of calling:
$(function() {
});
Example 2: document ready jquery
$(function() {
});
Example 3: jquery check if document loaded
jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:
$( handler )
$( document ).ready( handler )
$( "document" ).ready( handler )
$( "img" ).ready( handler )
$().ready( handler )