The following snippet of jquery says wait until the document is ready.
$(document).ready(function() {
// my code
});
what are other objects that can be passed to $() in place of document parameter.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
according to the docs:
The .ready() method can only be called on a jQuery object matching the current document
But my Fiddle shows that it’s not true!!!
HTML:
JavaScript:
Maybe what the docs meant is that
thisinside the handler will bedocumentobject and not the element corresponding to the selector?(which is true…)The code that fire the readyList handlers:
Anyway why wouldn’t you use the
documentobject? this is the only DOM object that will always be defined, not likebodyetc’.All three of the following syntaxes are equivalent:
$(document).ready(handler)$().ready(handler)(this is not recommended)$(handler)