Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does jQuery's noConflict function work?

Hey, I was just looking at the docs for the noConflict function and it says nothing about how it works (obviously). I just wondered if anyone knew.

Does it unset $? (delete window.$?)

Any suggestions will be much appreciated.

like image 443
Olical Avatar asked Feb 04 '11 12:02

Olical


2 Answers

You can check the source code:

// Map over the $ in case of overwrite
    _$ = window.$

//....
noConflict: function( deep ) {
        window.$ = _$;

        if ( deep ) {
            window.jQuery = _jQuery;
        }

        return jQuery;
    }
like image 193
Distdev Avatar answered Oct 01 '22 07:10

Distdev


It reverts $ to what it was before jQuery was loaded.

like image 30
Petah Avatar answered Oct 01 '22 05:10

Petah