2011-12-16 38 views
0

我在Jquery中得到腳本錯誤。請建議如何解決此問題。顯示的腳本錯誤消息是HTML解析錯誤:在子元素關閉之前無法修改父容器元素」。 代碼:0線:0炭:0。我的jQuery代碼是: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> 

當我刪除$( '#消息')對話框({});組件它不會拋出腳本錯誤。請告訴我原因。

+0

請格式化您的代碼 – epignosisx 2011-12-16 12:52:14

+1

...幷包含錯誤消息。 – 2011-12-16 12:53:27

回答

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(); 
}); 
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文件後?

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'); 
         } 
       } 
     });