2012-07-16 25 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); 
相关问题