JQuery中的脚本错误

时间:2011-12-16 12:51:36

标签: jquery

我在Jquery中收到脚本错误。请建议如何解决这个问题。显示的脚本错误消息是 HTML解析错误:无法在子元素关闭之前修改父容器元素。 代码:0 行:0 字符:0 。我的Jquery代码是:

      <script type="text/javascript">

     (function($) {
     var search=window.location.search.substring(1);
     var page=search.split("=");
     var location=window.location.toString();
     var url=location.split('?')[0];         

     if(page[1]=='custDetails'){

       $(document).ready(function(){
       $('#message').dialog('open');
       $(document).ready(function(){
       $('#pop').click(function(){
      $('#message').dialog('open');
       return false;
         });
       });
      });
     }   // end of if      
        else {
        $(document).ready(function(){
        $('#pop').click(function(){
        $('#message').dialog('open');
        return false;
          });
        });

        }  // end of else

        $('#message').dialog({
        width:200,
        autoOpen:false,
        buttons:{ 
           Close:function() {
       $ (this.dialog('close');
       $ ('#message').replaceWith('url');
                 }
              } 
          });

       $('#page').click((function(event){            
         window.print();
          });

        })  ($);
      </script>

当我删除 $('#message')。dialog({}); 组件它不会抛出脚本错误。请告诉我原因。

3 个答案:

答案 0 :(得分:1)

充满语法错误......

$('#message').dialog($  // << ERROR 1 should be {
        width:200; // << ERROR 2 the ; should be ,
        autoOpen:false; // << ERROR 3 the ; should be ,
        buttons.{close:function() { // << ERROR 4 the . should be :
       $ (this.dialog('close'); // << ERROR 5 the $(this should be $(this).
          }}
         });

一起应该是

    $('#message').dialog({
        width:200,
        autoOpen:false,
        buttons: { close:function() {
                          $(this).dialog('close');
                         }
                 }
        });

答案 1 :(得分:0)

如果有错误,你确定你包含了jQueryui js文件吗?有点像

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>

包含jQuery js文件后?

答案 2 :(得分:0)

这里有几个语法错误:

$('#message').dialog($
    width: 200;
    autoOpen: false;
    buttons. {
    close: function() {
        $(this.dialog('close');
        }
    }
});
$('#page').click((function(event) {
    window.print();
});

试试这个:

$('#message').dialog({
    width: 200,
    autoOpen: false,
    buttons: {
        close: function() {
            $(this.dialog('close');
            }
        }
    });
});

$('#page').click(function(event) {
    window.print();
});