[英]JQuery Dialog - Replace Timeout with close button
I am using the code below and decided I want a close button instead of the timeout. 我正在使用下面的代码,并决定我要关闭按钮而不是超时。
How can I replace the timeout with a close button with the code below? 如何用下面的代码用关闭按钮替换超时?
<script type="text/javascript">
$(document).ready(function() {
$("#info_box").dialog({
autoOpen: false,
modal: true,
width: 400,
zIndex: 9999999,
resizable: false,
open: function() {
// close the dialog 10 secs after it's opened
setTimeout(function() {
$(this).dialog("close");
}, 10000);
}
});
$(".notavailable").bind("click", function() {
$("#info_box").dialog("open");
});
});
</script>
You just need to add a buttons
property to the Object
the dialog
is created with, something like: 您只需要向创建
dialog
的Object
添加一个buttons
属性,例如:
$("#info_box").dialog({
autoOpen: false,
modal: true,
width: 400,
zIndex: 9999999,
resizable: false,
buttons: [
{
text: "Close",
click: function () {
$(this).dialog("close");
}
}
]
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.