2013-05-02 40 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