jQuery - Dollar signs and document references

I'm learning jQuery from the ground up and when I learn something, I want to know what is assumed, what has to be explicitly stated, and why one thing is done vs. another. As I go along, I'll be documenting my thoughts both for my own reference and for others who might want to know. Most of these posts will be very short and will seem simplistic to some but at least I'm blogging. :)

Basic jQuery Reference

$("document").ready(function(){})

In the code segment above, the dollar sign ($) is a mask for the jquery function in javascript and is the same as calling jQuery(). Note the capital Q in jQuery and remember that javascript is case sensitive. On the other hand, we'll see that there are parts of jQuery that are not case sensitive. As a basic rule, assume that tags and tag attribute names are not case sensitive while tag and attribute content is. For example br, Br, BR, and bR are all treated the same whole name="Michael" and name="michael" are different.

Continuing on, the "document" reference tells jQuery that it is operating on the called page - the document. As jQuery has nothing else to work on, "document" can be assumed and you can use $() instead. I don't think that there is any advantage or disadvantage to explicitly stating "document". Actually, some people don't even know that "document" is assumed.

Comments
johans's Gravatar If you place your scripts just before the closing body tag then you do not need to use $()
# Posted By johans | 9/15/09 1:27 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner
House of Fusion | ColdFusion Jobs @ House of Fusion | Fusion Authority