top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What does dollar sign ($) means in jQuery?

+1 vote
438 views
What does dollar sign ($) means in jQuery?
posted Dec 9, 2015 by Latha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Dollar Sign is nothing but it's an alias for JQuery. Take a look at below jQuery code.

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

jQuery(document).ready(function(){
});
answer Dec 9, 2015 by Shivaranjini
+1 vote

Javascript Dollar Sign. A beginner, or even a seasoned JavaScript programmer may be slightly intimidated having once spotted something as ambiguous as the dollar sign ($) in JavaScript code. Seeing for the first time the usage of the Dollar Sign, it may be difficult to grasp having not read any books about JavaScript and jQuery. To explain the usage of the dollar sign in JavaScript code, I need to lay out some general details. In JavaScript, the dollar sign commonly appears in variable definitions and function calls. Let me assure you that there is nothing mysterious about the dollar sign, for it is just a variable (or an identifier) name. There is nothing Greek about it. As an example of this, the insanely popular JavaScript framework, about which I had previously written an article (What is jQuery?) uses the dollar sign to instantiate the main jQuery object.

{$AD468-60}In many computer programming languages or script languages a variable is also referred to as an identifier. Each programming language has a design whether it be C, C++, PHP, Java or Javascript. Each language design also has a set of rules. For example, in JavaScript the rules for defining variables is that each identifier must start with a letter, the dollar sign ($) or the underscore character (_) and must never start with a digit (such as 0-1) or some of the other characters such as punctuation signs and a few others (because that would confuse the crap out of the compiler). Both of these symbols ($ and _) are special cases and may also appear in the rest of the identifier name. So, as an example, a variable identifier named by five consequent dollar signs such as $$$$$ (or five, or another number of underscores in a row, for that matter) is totally acceptable because it falls within the rules of the JavaScript language syntax. This is simply a language rule that JavaScript programmers must live with. And believe me, there are very good reasons for that.

Once upon a time, there was a global function object, whose identifier’s name was a single dollar sign $. This coding practice (lack of the var keyword) was undesirable by the skilled and the aged programmers, because we do not favor global variables in our JavaScript code unless we are cheating. However, the important part is that this function could have been named almost anything such as: a, z or even a single underscore: _

// An example of legal identifier names

var A = function() {
    alert("function A was called");
}

var $ = function() {
    alert("function $ was called");
}

var _ = function() {
    alert("function _ was called");
}
answer Dec 9, 2015 by Manikandan J
...