-2

I am very new to javascript and I am looking very often on the internet for guides and explanation. The one thing that keeps on coming back is this $ sign in the code. I can not get my head around what this means. Is this only used in an older version of js?

Here is an example of code.

    $(document).ready(function(){
    //initial
       $('#content').load('content/index.php');
    });
       //handle menu clicks 
       $('#Kevin li a').click(function(){
           alert("hi");
       });
    });
  • `$` is just a variable identifier http://stackoverflow.com/questions/1661197/what-characters-are-valid-for-javascript-variable-names and in this case it is being used by jQuery, based on the example you have posted. – Xotic750 Dec 30 '15 at 11:02
  • Try this in your console: `var $ = "dollar-sign"; console.log($); ` – DontVoteMeDown Dec 30 '15 at 11:13

3 Answers3

2

The $ sign is an identifier for variables and functions. You can look at

http://www.authenticsociety.com/blog/JavaScript_DollarSign

mck
  • 978
  • 3
  • 14
  • 38
0

$ is used as a shortcut to access jQuery functions. jQuery is a library that simplifies working with the DOM, and many other things.

Stephan Leclercq
  • 893
  • 7
  • 11
0

$ is not a sign/symbol belongs to the javascript, its belong to some of its libraries, such as jQuery.

Have a look at this suggested in answer to another question

Community
  • 1
  • 1
Ali
  • 2,993
  • 3
  • 19
  • 42