jQuery sign ($)


There are many developers they use always a dollar in scripts but don't know why. They will always be unsure about whether to use the dollar sign or jQuery. Dollar Sign is nothing but it's an alias for JQuery then an alias for a function. You can write jQuery at the place of $.

 Syntax

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

Above and below syntax are same.

Syntax

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

Example

You may see code like this.

// Using the $ alias to select elements with jQuery
  $('#elementID').addClass('active');

In this example, $ is used as a shorthand for the jQuery object, which allows you to select an element with the elementID and add the CSS class active to it.


Prev Next