drxyaox153896
2012-07-16 09:21 阅读 61

当我向html页面添加两个脚本时..一个不起作用[关闭]

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条回答 默认 最新

  • 已采纳
    doufencigui933699 啊啊啊小孔 2012-07-16 09:25

    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.

    点赞 评论 复制链接分享
  • duanchao5258 duanchao5258 2012-07-16 09:28

    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>
    
    点赞 评论 复制链接分享
  • dongsuoxi1790 dongsuoxi1790 2012-07-16 09:55
    ( function($$$) {
    
        $$$(document).ready(function(e) {
            //Code here
        });
    
    } ) ( jQuery ); 
    
    点赞 评论 复制链接分享

相关推荐