When I add two scripts to a html page..one is does

2020-04-18 06:12发布

I created two jquery and and script tags to calender an confirmation ..but when they are in seperate html pages it works well..but it doesnt work when the two scripts are in the same page..Why is that?

<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>

3条回答
可以哭但决不认输i
2楼-- · 2020-04-18 06:49
( function($$$) {

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

} ) ( jQuery ); 
查看更多
Juvenile、少年°
3楼-- · 2020-04-18 06:53

Try reordering your scripts, it might be causing the problem. You had jQuery in multiple times, this is more than likely the cause of your problems.

Also you should try formatting your code to make it clearer what is going on. For example i have put the script type tags at the start for easier readability.

Have you specifically put Cancel with no quotes in your dialog? Ive corrected this below.

<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>
查看更多
够拽才男人
4楼-- · 2020-04-18 07:04

Have a look at jQueries no conflict. http://api.jquery.com/jQuery.noConflict/

This makes it so you can use certain functions from different jQuery versions/libraries.

查看更多
登录 后发表回答