What is $ ?


In our first example of jQuery we have seen the "hello world" example with the significance of document.ready event but there is a concept which may be striking in your mind i.e. what is $ which is used. recall the line which says: 
 
$(document).ready(function(){  
//lines of code.... 
 }); 
 
Now here the $() is a predefined function of the jQuery library and allows us to use different objects or functions available in the jQuery library. 
 
$() returns a JS object containing an array of DOM elements. 
 
$ and jQuery are synonyms in usage. For example: 
 
$(selector) or, 
jQuery(selector) 
 
either of the above forms can be used where selector is the DOM element or array of elements which we want to refer. 
 
If you want to use any other symbol or name instead of the $ or jQuery then you can use the "NoConflict" method like the following: 
 
var jQ=jQuery.noConflict(); 
 
Now you can use jQ just like jQuery or $ like the following: 
 
jQ(document).ready(function(){ 
//lines of code 
}); 
 
So now i think its clear to you, what is meant by $ and about its significance in jQuery. 
 
Now come to another point, in $ when we write "document" word then what is the significance of that. 
 
So the answer is simple that "document" is a DOM element which is selected by $ keyword and after selecting this DOM element we can refer to jQuery for the different built-in functions like ready(), and accomplish our tasks easily. 
 
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments