hide - Understanding jQuery
hide - Understanding jQuery
hide - Understanding jQuery
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Why does <strong>jQuery</strong> do exactly the same thing even though the second parameter passed in two<br />
different ways? The typeof function to the rescue. The <strong>jQuery</strong> function written in such a way<br />
that it first determines the type of the object being passed to it as a parameter.<br />
If the context parameter is a string like “body” it will take its literal meaning and find that<br />
element using the text in the string. If the parameter is passed as an object (remember that<br />
$(“body”) is a function that actually returns an object) then the work is already done - we already<br />
have the object here.<br />
Internally, the $ function will skip the seeking algorithm (since the object already contains all<br />
the data.) This doesn’t mean that it’s faster, $(“body”) will still take time to obtain the object<br />
itself, it’s just that it’s done before this object is passed to the main <strong>jQuery</strong> function for processing.<br />
58