这段代码运行得非常完美,但是——对话框窗口不会在我期望的X毫秒后关闭...
setTimeout
函数被执行(我在那里放置了alert()并且它起作用了...),所以我想问题可能出在$("#alert div").dialog('close');
上,但我不知道哪里出错了...
if ($("#alert").length) {
var title;
if ($("#alert span").length) {
title = $("#alert span").text();
}
$("#alert div").dialog({
title: title,
modal: true,
open: function() {
setTimeout(function() {
$("#alert div").dialog('close');
}, 2000);
}
});
}
编辑: 如果有帮助的话,这是HTML:
<div id="alert">
<span>Password change</span>
<div>Password was successfully changed.</div>
</div>
已解决! 如果有人知道为什么我的代码不起作用,那就太好了...