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.
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;
}
It reverts $
to what it was before jQuery was loaded.
精彩评论