Response title
This is preview!
$(function(){
});
jQuery(document).ready(function(){
});
$(document).ready(function(){
});
$(document).on('ready', function(){
})
The \ method is not a ECMAScript (JavaScript) standard.Is it safe?
Some browsers do not allow spaces behind the \ character.
There is alsoAlso the reasons for choosing the shortest syntax are explained better:$(document).on( "ready", handler )
, deprecated as of jQuery 1.8 and removed in jQuery 3.0. Note that if the DOM becomes ready before this event is attached, the handler will not be executed.
$( handler )
$( document ).ready( handler )
$( "document" ).ready( handler )
$( "img" ).ready( handler )
$().ready( handler )
As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated. This is because the selection has no bearing on the behavior of the.ready()
method, which is inefficient and can lead to incorrect assumptions about the method's behavior. For example, the third syntax works with"document"
which selects nothing. The fourth syntax waits for the document to be ready but implies (incorrectly) that it waits for images to become ready.
© 2013 jQuery Foundation
Sponsored by and others.