Reputation: 5578
I am not familiar with this syntax. What does the $.
mean before the function call?
Upvotes: 4
Views: 8659
Reputation: 22421
$ - is just an object name, since $ is valid symbol in JavaScript identifiers. This is not some special syntax, just a regular retrieving of 'functionName' property from object and calling it. Some libraries (like jQuery, for example) alias their main object to this short name to make calls take less space.
Upvotes: 1
Reputation: 2435
Over here $ sign can be replaced with "jQuery " keyword.
$.functionName();
is the same as
jQuery.functionName();
if you are using jQuery framework. If using something else, it may refer to base object as in jQuery.
Upvotes: 3
Reputation: 8424
The dollar sign function has become the more-or-less de facto shortcut to document.getElementById().
http://osric.com/chris/accidental-developer/2008/04/the-javascript-dollar-sign-function/ Check this
And is used by Jquery, Mootools or any other javascript frameworks. Even you can make one
This is a small example
function $(obj) {
return document.getElementById(obj);
}
Upvotes: 2
Reputation: 34581
$
is just a name of some object. It could be jQuery, or Prototype, in case you're using one of these libraries.
So $.functionName()
simply stands for calling a function named functionName
of the object named $
.
Upvotes: 7
Reputation: 5546
This is alias for JQuery object or Prototype or MooTools. Also you can see _. - Underscore.
Upvotes: 0