当我在一个html页面上添加两个脚本时,其中一个不起作用
When I add two scripts to a html page..one is doesnt work
我创建了两个jquery和script标记来日历确认。。但当它们在单独的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>
尝试重新排序脚本,这可能会导致问题。您多次使用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>
( function($$$) {
$$$(document).ready(function(e) {
//Code here
});
} ) ( jQuery );
看看jQueries没有冲突。http://api.jquery.com/jQuery.noConflict/
这使得您可以使用不同jQuery版本/库中的某些函数。