Last active
August 29, 2015 14:07
-
-
Save RyoSugimoto/a262647473a71d846c94 to your computer and use it in GitHub Desktop.
異なるバージョンのjQueryを共存させる方法。
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
<script src="../../common/js/jquery-2.1.1.js"></script> | |
<script> | |
// 新しいバージョンのjQueryを変数に格納 | |
var $2_1_1 = $.noConflict(); | |
</script> | |
<script src="../../common/js/jquery-1.11.1.js"></script> | |
<script> | |
alert($2_1_1.fn.jquery); // 2.1.1 | |
alert($.fn.jquery); // 1.11.1 | |
</script> |
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
<script src="../../common/js/jquery-1.11.1.js"></script> | |
<script src="../../common/js/jquery-2.1.1.js"></script> | |
<script> | |
var $2_1_1; | |
alert($.fn.jquery); // 2.1.1 | |
$2_1_1 = $.noConflict(true); // trueを渡すと、グローバルから削除される | |
alert($.fn.jquery); // 1.11.1 | |
alert($2_1_1.fn.jquery); // 2.1.1 | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment