Two jQuery versions on the same page

后端 未结 3 1899
故里飘歌
故里飘歌 2020-12-01 11:17

Is it possible to have 2 different jQuery versions in the same document, and have them to not collide with each other?

For example if I create a bookmarklet and want

3条回答
  •  一整个雨季
    2020-12-01 11:51

    jQuery comes with a way to avoid collisions. After you load the first version, you can assign it to a different variable.

    var $j = jQuery.noConflict();
    

    And then load your second jQuery version. The first one you load can be accessed with $j(...) while the second one can be accessed with $(...).

    Alternatively, somebody made a little helper in an attempt to make it easier to switch between different versions.

提交回复
热议问题