Skip to content

Instantly share code, notes, and snippets.

@fwon
Last active August 29, 2015 14:04
Show Gist options
  • Save fwon/ed5843594602bfc0d23f to your computer and use it in GitHub Desktop.
Save fwon/ed5843594602bfc0d23f to your computer and use it in GitHub Desktop.
jQuery noConflict
// 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