jQuery Prefixes: jQuery vs. $

It's a really common practice in jQuery to use the dollar sign ($) prefix with your methods, like this:

$(document).ready(function(){
$(#myDiv).slideUp();
})

The above code would make the div with the ID #myDiv slide up when the page loads. But that's not the only way to write that function. Sometimes you might see it written with the word jQuery in place of the $ symbol:

jQuery(document).ready(function(){
jQuery(#myDiv).slideUp();
})

The two prefixes $ and jQuery are essentially interchangeable with each other because of the function that can be found in the jQuery source code:

window.jQuery = window.$ = jQuery

The function above basically defines $ as an alias for jQuery, so go ahead and use them interchangeably in jQuery.



Responsive Menu
Add more content here...