2012-07-16 24 views
1

我創建了兩個jquery和腳本標記日曆日曆確認..但是當他們在單獨的HTML頁面,它運作良好..但它不工作時這兩個腳本是在同一頁...這是爲什麼?當我添加兩個腳本到一個HTML頁面..一個不工作

<script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"></script> 
<script src="Scripts/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script> 
<script> 

$(document).ready(function(){ 

$('#click').click(function(){ 
    //$(function() { 
     // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore! 
     $("#dialog:ui-dialog").dialog("destroy"); 

     $("#dialog-confirm").dialog({ 
      resizable: false, 
      height:140, 
      modal: true, 
      buttons: { 
       "Ok": function() { 

        $('#form1').submit(); 
       }, 
       Cancel: function() { 
        $(this).dialog("close"); 
       } 
      } 
     }); 
    }); 
    }); 
</script> 

<script type="text/javascript" src="jquery/jquery.min.js"></script> 
<script type="text/javascript" src="jsdatepick-calendar/jquery.1.4.2.js"></script> 
<script type="text/javascript" src="jsdatepick-calendar/jsDatePick.jquery.min.1.3.js"></script> 
<script type="text/javascript" src="jquery/fadeslideshow.js"></script> 
+2

你什麼錯誤?你爲什麼要加載jQuery庫的多個版本? – Quentin 2012-07-16 09:23:23

+1

有人可能會覆蓋其他..請解釋你的原因/錯誤點 – satdev86 2012-07-16 09:25:04

+2

可能是因爲你正在加載jQuery兩次。 – 2012-07-16 09:25:59

回答

0

看看jQueries沒有衝突。 http://api.jquery.com/jQuery.noConflict/

這使得您可以使用不同的jQuery版本/庫中的某些功能。

+5

或者,清理您的代碼並使用一個版本(並節省帶寬和加載時間) – 2012-07-16 09:27:22

4

嘗試重新排序腳本,它可能會導致問題。你有多次jQuery,這很可能是你的問題的原因。

此外,你應該嘗試格式化你的代碼,使其更清楚發生了什麼。例如,我已將腳本type標籤放在起始位置以便於閱讀。

你有沒有在你的對話框中特別加上Cancel沒有引號?我修正了下面的內容。

<script type="text/javascript" src="Scripts/jquery-1.7.2.min.js" ></script> 
<script type="text/javascript" src="Scripts/jquery-ui-1.8.21.custom.min.js"></script> 
<!--jQuery again here?--><script type="text/javascript" src="jsdatepick-calendar/jsDatePick.jquery.min.1.3.js"></script> 
<script type="text/javascript" src="jquery/fadeslideshow.js"></script>  
<script type="text/javascript"> 

$(document).ready(function(){ 

    $('#click').click(function(){ 

     $("#dialog:ui-dialog").dialog("destroy"); 

     $("#dialog-confirm").dialog({ 
      resizable: false, 
      height: 140, 
      modal: true, 
      buttons: { 
       "Ok": function() { 
        $('#form1').submit(); 
       }, 
       "Cancel": function() { 
        $(this).dialog("close"); 
       } 
      } 
     }) 
    }) 
}); 
</script> 
1
(function($$$) { 

    $$$(document).ready(function(e) { 
     //Code here 
    }); 

}) (jQuery); 
相關問題