I have read some articles about the titled cited but not found anything from which i could understood. Can anyone please tell me what is the purpose of "$varName"? why we use "$" sign before a variable?
Asked
Active
Viewed 535 times
0
-
2$ sign just helps you to notice that the variable contains jQuery object. There's nothing else about it other than coding style preference. This question was asked many times here though, it's weird if you couldn't find it. For example, here: https://stackoverflow.com/questions/22329185/in-jquery-what-is-the-difference-between-using-the-dollar-sign-vs-var – Dmitry Gamolin Dec 01 '16 at 09:05
-
1There is no difference, that's just a convention to use $ as prefix for varibale name refering for example to a jq object – A. Wolff Dec 01 '16 at 09:05
-
1It's purely a naming convention. The `$` prefix means this variable holds a jQuery object. – Rory McCrossan Dec 01 '16 at 09:05
-
1It's a common convention that variables prefixed with `$` are denoting a jQuery context (as opposed to a native `HTMLElement`). So you can further call jQuery methods on it (like `$myDiv.show()` for example). – haim770 Dec 01 '16 at 09:05