Jquery 自动关闭模式窗口?如何使模态窗口在一段时间后自动关闭?
如何使模态窗口在一段时间后自动关闭 例如:。窗口弹出,现在我想在2秒钟后窗口将关闭 代码如下:Jquery 自动关闭模式窗口?如何使模态窗口在一段时间后自动关闭?,jquery,modal-dialog,Jquery,Modal Dialog,如何使模态窗口在一段时间后自动关闭 例如:。窗口弹出,现在我想在2秒钟后窗口将关闭 代码如下: <div class="remodal-bg"gt; ...Ваш контент... </div> <div class="remodal" data-remodal-id="modal"> <h1>Remodal</h1> <p> Flat, responsive, lightweight, fast
<div class="remodal-bg"gt;
...Ваш контент...
</div>
<div class="remodal" data-remodal-id="modal">
<h1>Remodal</h1>
<p>
Flat, responsive, lightweight, fast, easy customizable modal window plugin
with declarative state notation and hash tracking.
</p>
<br>
<a class="remodal-cancel" href="#">Cancel</a>
<a class="remodal-confirm" href="#">OK</a>
</div>
<a href="#modal">Call the modal with data-remodal-id="modal"</a>
$(document).on('open', '.remodal', function () {
// открытие окна
var modal = $(this);
});
$(document).on('opened', '.remodal', function () {
// окно открыто
var modal = $(this);
});
$(document).on('close', '.remodal', function () {
// закрытие окна
var modal = $(this);
});
$(document).on('closed', '.remodal', function () {
// окно закрыто
var modal = $(this);
});
$(document).on('confirm', '.remodal', function () {
// нажатие на кнопку подтверждения
var modal = $(this);
});
$(document).on('cancel', '.remodal', function () {
// нажатие на кнопку отмены
var modal = $(this);
});
<script>
var options = {...};
$('[data-remodal-id=modal]').remodal(options).open();
</script>
var inst = $.remodal.lookup[$('[data-remodal-id=modal]').data('remodal')];
// открыть модальное окно
inst.open();
// закрыть модальное окно
inst.close();
此注释可在您链接到的页面的源中找到:
// You can open or close it like this:
// var inst = $.remodal.lookup[$('[data-remodal-id=modal]').data('remodal')];
// inst.open();
// inst.close();
所以你可以在setTimeout中结束
setTimeout(inst.close, 2000);
您可以向open
事件添加一个侦听器,然后添加一个timeout
时间2000
毫秒,以在该时间之后关闭它
$(document).on('open', '.remodal', function () {
console.log('open');
setTimeout(function(){$(this).remodal('close');},
2000);
});
请在问题中输入相关代码,而不是链接到它。我们不希望为了帮助您而必须下载您的代码。Ir sys可能重复:“未捕获类型错误:无法读取未定义jquery.js:5986 dt jquery.js:5986 x.extend.buildFragment jquery.js:6543 x.fn.extend.domManip jquery.js:6237 x.fn.extend.append jquery.js:6047 Remodal.buildDOM jquery.Remodal.js:117 Remodal jquery.Remodal.js:98(匿名函数)jquery.remodal.js:238 x.extend.each jquery.js:657 x.fn.x.each jquery.js:266$.fn.(匿名函数)jquery.remodal.js:235(匿名函数)