1ç»é¢å ã§ãã¼ã¸ã§ã³ã®ç°ãªãjQueryãå ±åãããã«ã¯
ããã¾ãåããããªåé¡ã«ç´é¢ãã¦ãã人ã¯å°ãªãã¨ã¯æãã¾ããããã
ã¾ããæ®éã«jQueryã2åå¼ãã§ã¿ã¾ãã
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
ãã®ããã«ããå ´åãjQueryã®ã°ãã¼ãã«ãªãã¸ã§ã¯ãã§ããã$ãã¾ãã¯ãjQueryãã¯å¾åã¡ã«ãªãã®ã§ãalert($().jquery)ã¨ãããã¨1.9.0ã表示ããã¾ãã1.3.2ã®jQueryãªãã¸ã§ã¯ãã¯ä¸æ¸ããã¦æ¶ãã¦ãã¾ã£ã¦ãã¾ãã
ã§ã¯ã©ããããã¨ããã¨noConflictã使ãã¾ããprototype.jsã¨åå± ããã¨ãã«ãã使ãã¾ããã
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> var $132 = $.noConflict(true); </script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
noConflictã®å¼æ°ã«trueãæå®ãããã¨ã§jQueryãªãã¸ã§ã¯ããå®å ¨ã«å¥åã§æ¸ãæãããã¨ãã§ãã¾ãã
åèï¼jQuery.noConflict(extreme) - jQuery 日本語リファレンス
ä¸è¨ã®ã³ã¼ããä¾ã«åãã¨ãã$132ãã¯1.3.2ã®jQueryãªãã¸ã§ã¯ãããã$ããjQueryãã¯1.9.0ã®jQueryãªãã¸ã§ã¯ããå ¥ã£ã¦ãã¾ãã
ããã§åå± ã§ããããã«ãªãã¾ããã
ããä¸æ©é²ãã§ããã®ç¶æ ãã1.3.2ã§ãã使ããªãã©ã¤ãã©ãªã¨1.9.0ã§ãã使ããªãã©ã¤ãã©ãªãåæã«ä½¿ãããå ´åã«ã¤ãã¦ã
ãã®å ´åã¯ãã©ã¤ãã©ãªå
ã®jQueryãªãã¸ã§ã¯ãã$132ã§å
¨ç½®æãã¦ãã¾ãã°åãããã«ãªãã¾ãã
ããé常ã«æéããããã®ã§ãããããã¾ããããã®å ´åã¯ã¯ãã¼ã¸ã£ã使ãã¨ã¹ãã¼ãã§ãã
ã©ã¤ãã©ãªãéãã¦ä»¥ä¸ã®ã³ã¼ãã追å ãã¾ãã
(function($){ // ã©ã¤ãã©ãªæ¬ä½ã®javascriptã»ã»ã» })($132)
ãããããã¨ã§ãã©ã¤ãã©ãªå
ã®ã¿ã$ãã¯ã$132ããè¦ãããã«ãªãã¾ãã
ãã¾ã«ã©ã¤ãã©ãªå
ã§ã$ãã¨ãjQueryããæ··ãã£ã¦ä½¿ããã¦ããå ´åãããã®ã§ãã©ã¡ããã«çµ±ä¸ããããã«ã©ã¤ãã©ãªãä¿®æ£ãã¦ãã ããã