2017-02-18 63 views
0

這裏是我正在使用網頁查看詳細資料...無法解析的jQuery noconflict多個版本

<!--------slider script-------------> 
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> 

<!---------------------anchor tag smooth scroller on same page--> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 


<!----smooth scrooler up---> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> 

當我要使用所有這三個腳本平行然後滑塊腳本不工作,所以給我解決方案我怎麼可以一起使用所有。

+2

在頁面中包含** 3 **版本的jQuery(包括*非常*舊版本)是災難的祕訣。查找使用最新版本庫的積極支持的小部件,並只使用一個。 – Pointy

+0

[我可以在同一頁上使用多個版本的jQuery嗎?](http://stackoverflow.com/questions/1566595/can-i-use-multiple-versions-of-jquery-on-the-same -page) –

+0

'你能推薦我最新版本還是下載鏈接? @Pointy' –

回答

1

使用jQuery.noConflict()函數,你可以在同一頁面上放置多個jQuery。
例如,

<!--------slider script-------------> 
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> 
var j1 = jQuery.noConflict(); 

<!---------------------anchor tag smooth scroller on same page--> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
var j2 = jQuery.noConflict(); 

<!----smooth scrooler up---> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> 
var j3 = jQuery.noConflict(); 

j1(document).ready(function($) { /* write script here */ } 
j2(document).ready(function($) { /* write script here */ } 
j3(document).ready(function($) { /* write script here */ } 

希望這會幫助你。