Thread:Mathmagician/@comment-3508190-20120504092551/@comment-3508190-20120509031740

$ is an alias for jQuery. You can write jQuery('#someID') instead of $('#someID') if you like. Same thing. Just shorter ;)

So yes, if you see a $ sign in JavaScript code you can be 99% sure, you're looking at jQuery.

The jQuery function/object is HEAVILY overloaded. I'm not sure I know all of its uses myself, so I'll give you a few examples from the top of my head:

If you call $ with a string such as $('#id') or $('span.class') it's interpreted exactly like a CSS selector and returns an HTML element (wrapped in a jQuery object).

An exception are strings that start with &lt; and end with &gt;. They're interpreted as HTML constructors:

The other thing that you can see in the example above is that most jQuery "methods" - like append e.g. - accept the similar parameters as $ does.

When you pass an object to $ it is assumed to be an HTML element. That's often used with event handlers:

And lastly, when you use $ with a function:

It is an equivalent to jQuery's "ready" function:

The useage of "method" and "function" is really just lingo. There's no deeper meaning behind it. The jQuery docs call everything that extends $ a function and everything that extends $ a method. That's all.

Practically that means that "methods" always return *this*:

That makes it possible to chain calls. That's called a "fluid" interface. To be more precise: jQuery maintains an internal stack, that means that jQuery methods do not necessarily operate on a single object. The above example operates on all anchor nodes, that have parent nodes of CSS class "some-class" and assigns them a title attribute.

"Functions" are used for various utility functions that do not return *this*

The point of all that overloading and re-using is that jQuery effectively adds only a single symbol to the global namespace: $ (Actually it's two symbols "jQuery" and "$")