[英]How can I replace an alert box with a dialog box?
如何將警報框更改為jquery對話框?
腳本編碼部分:
if(answeredAnsData.length==8){
for(var x=0;x<8;x++){
$('#text'+(x)).attr('disabled','disabled');
}
window.alert("test"); //alert box here
}
});
您應該使用確認命令
window.confirm("are you sure");
如果要使用jquery中的對話框,則應查看ui擴展。 示例取自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”圖標移動,調整大小和關閉。
我們可以使用確認
結果=確認(“確認單擊確定”);
要查看所有選項, 請訪問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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.