Last active
August 29, 2015 14:04
-
-
Save fwon/ed5843594602bfc0d23f to your computer and use it in GitHub Desktop.
jQuery noConflict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Map over jQuery in case of overwrite | |
_jQuery = window.jQuery, | |
// Map over the $ in case of overwrite | |
_$ = window.$, //前面有引入其他库时,为它的$,没有引入时,则为undefined | |
noConflict: function( deep ) { | |
if ( window.$ === jQuery ) { | |
window.$ = _$; | |
} | |
if ( deep && window.jQuery === jQuery ) { | |
window.jQuery = _jQuery; | |
} | |
return jQuery; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment