Home Ask Login Register

Developers Planet

Your answer is one click away!

Danish iqbal February 2016

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

As the Title says, kindly someone explain the use of $ sign in functoin. I am using this code to smooth scroll to ID in WordPress.

When i remove $ sign, code does not work. I have to pass $ in function. kindly refer to image.

Note: This code works without passing $ in function when using in HTML website but does not work in WordPress. Well, that nothing to worry but if some one could explain?

Below is the code:

    $('.scroll').on('click',function (e) {

        var target = this.hash;
        var $target = $(target);

        $('html, body').stop().animate({
            'scrollTop': $target.offset().top
        }, 900, 'swing', function () {
            window.location.hash = target;


Axel Amthor February 2016

The $ is the name of a variable. It is equivalant to jQuery variable. Assume this code:

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

no magic about it, just a name.

Post Status

Asked in February 2016
Viewed 3,535 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life