2013-05-02 58 views
0

如何將警報框更改爲jquery對話框?腳本編碼的如何使用對話框替換警告框?

部分:

if(answeredAnsData.length==8){ 
      for(var x=0;x<8;x++){ 
       $('#text'+(x)).attr('disabled','disabled'); 
      } 
     window.alert("test"); //alert box here 
     } 
    }); 

回答

3

,如果你想要使用jQuery的對話框中,你應該看看UI擴展,您應該使用confirm命令

window.confirm("are you sure"); 

。從http://jqueryui.com/dialog/

<!doctype html> 

<html lang="en"> 
<head> 
    <meta charset="utf-8" /> 
    <title>jQuery UI Dialog - Default functionality</title> 
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /> 
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
    <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script> 
    <link rel="stylesheet" href="/resources/demos/style.css" /> 
    <script> 
     $(function() { 
      $("#dialog").dialog(); 
     }); 
    </script> 
</head> 
<body> 

拍攝的實施例,這是默認對話框是用於顯示信息是有用的。對話窗口可以移動,調整大小並用'x'圖標關閉。

+0

抱歉..我的意思是jQuery的對話框.. – 2013-05-02 06:32:39

+0

添加從jQuery用戶界面的對話框中的例子,加入jQuery的參考您的問題 – MatthiasLaug 2013-05-02 06:37:20

+0

是否解決了您的問題? – MatthiasLaug 2013-05-02 13:45:05

1

我們可以使用確認

結果=確認( 「確認點擊OK」);

要查看所有選項http://www.w3schools.com/js/js_popup.asp

使用jQuery對話框

<html lang="en"> 
<head> 
<meta charset="utf-8" /> 
<title>jQuery UI Dialog - Default functionality</title> 
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /> 
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script> 
<link rel="stylesheet" href="/resources/demos/style.css" /> 
<script> 
$(function() { 
$("#dialog").dialog(); 
}); 
</script> 
</head> 
<body> 
<div id="dialog" title="Basic dialog"> 
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p> 
</div> 
</body> 
</html> 
+0

可以改成jquery對話框嗎?而不是窗口框。 – 2013-05-02 06:35:23

+0

你想要這樣的對話框嗎? http://jqueryui.com/dialog/ – Raji 2013-05-02 06:37:15

+0

yaya,你是對的..但我不知道..如何申請.. 我嘗試使用此代碼..它仍然無法正常工作, result ='

test.
「; – 2013-05-02 06:40:02