您的位置:首页 > Web前端 > JQuery

jQuery命名空间无冲突

2016-02-15 11:28 651 查看
var
2     // Map over jQuery in case of overwrite
3     _jQuery = window.jQuery,
4
5     // Map over the $ in case of overwrite
6     _$ = window.$;
7
8 jQuery.noConflict = function( deep ) {
9     if ( window.$ === jQuery ) {
10         window.$ = _$;
11     }
12
13     if ( deep && window.jQuery === jQuery ) {
14         window.jQuery = _jQuery;
15     }
16
17     return jQuery;
18 };


先将全局的$和jQuery保存到局部变量_$和_jQuery中

然后将jQuery返回给一个全局命名空间
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: