What does dollar sign ($) means in jQuery ? - GeeksforGeeks

19 Jul, 2021
The $ sign is nothing but an identifier of jQuery() function. 
Instead of writing jQuery we simply write $ which is the same as jQuery() function. A $ with a selector specifies that it is a jQuery selector. It is given a shorter identifier as $ just to reduce the time for writing larger syntax. It contains all the functions that are used by a jQuery object such as animate(), hide(), show(), css() and many more. Moreover, in terms of memory, $ is better than jQuery because $ takes a byte and jQuery takes 6 bytes which have the same functionality. 
Syntax:
$('selector').action();
Example 1: A simple illustration to show jQuery and $ have the same functionality.
HTML
!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <meta name="viewport"           content="width=device-width, initial-scale=1.0">        <!-- Including jQuery  -->    <script src="https://code.jquery.com/jquery-3.6.0.min.js"            integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="            crossorigin="anonymous">    </script></head>  <body>        <script>       console.log($===jQuery)    </script></body>  </html>
Output:
true
Note: $(‘p’) and jQuery(‘p’) have the same meaning, and they return the same objects.
Example 2:
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <meta name="viewport"           content="width=device-width, initial-scale=1.0">          <!-- Including jQuery  -->    <script src="https://code.jquery.com/jquery-3.6.0.min.js"            integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="            crossorigin="anonymous">   </script></head>  <body>    <p> This is a paragraph</p>    <script>      var p = $('p').text();      var x = jQuery('p').text()      console.log(p);      console.log(x);    </script></body></html>
Output:
We can even change the $ by using jQuery noConflict() function because there may be chances when we are using other technologies which may have different meaning, in such cases we can have our customized identifier for jQuery using noConflict() method.
Syntax:
var new_identifier = jQuery.noConflict();
Example 3:
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <meta name="viewport"           content="width=device-width, initial-scale=1.0">        <!-- Including jQuery  -->    <script src="https://code.jquery.com/jquery-3.6.0.min.js"            integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="             crossorigin="anonymous">    </script></head>  <body>      <p> This is a paragraph</p>      <script>      var dollar =  jQuery.noConflict();        // We can use dollar instead of $ by       // using jQuery noConflict() method      var x = dollar('p').text()      console.log(x);    </script></body>  </html>
Output:
This is a paragraph
jQuery-Questions
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Show and Hide div elements using radio buttons?
How to prevent Body from scrolling when a modal is opened using jQuery ?
jQuery | ajax() Method
jQuery | removeAttr() with Examples
How to get the value in an input text box using jQuery ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills