Passing $ in jQuery function. What's the use of $ sign? -


this question has answer here:

as title says, kindly explain use of $ sign in functoin. using code smooth scroll id in wordpress.

when remove $ sign, code not work. have pass $ in function. kindly refer image.

note: code works without passing $ in function when using in html website not work in wordpress. well, nothing worry if 1 explain?

below code:

$(document).ready(function($){     $('.scroll').on('click',function (e) {         e.preventdefault();          var target = this.hash;         var $target = $(target);          $('html, body').stop().animate({             'scrolltop': $target.offset().top         }, 900, 'swing', function () {             window.location.hash = target;         });     }); }); 

the $ name of variable. equivalant jquery variable. assume code:

var $ = "my $ variable"; alert ($); 

no magic it, name.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -