最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How does jQuery's noConflict function work? - Stack Overflow

programmeradmin4浏览0评论

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.

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.

Share Improve this question asked Feb 4, 2011 at 12:04 OlicalOlical 41.4k12 gold badges57 silver badges77 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 10

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.

发布评论

评论列表(0)

  1. 暂无评论