-
-
Save yuka2py/6148288 to your computer and use it in GitHub Desktop.
ページ内のjQueryの有無に関わらず、別のjQueryをロードしてスクリプトで利用する。既存のjQueryがあれば、それを変更しない。
ブックマークレットなどでの利用を想定。
This file contains 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
(function(func){ | |
var jq = document.createElement('script'); | |
jq.src = '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js'; | |
jq.async = 1; | |
jq.onload = function() { | |
document.body.removeChild(jq); | |
func(jQuery.noConflict(true)); | |
}; | |
document.body.appendChild(jq); | |
})(function($){ | |
alert($().jquery); //2.0.3 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jsdo.it での確認コード:http://jsdo.it/yuka2py/load-another-jquery