twitter-bootstrap Bootstrap 延迟后隐藏模态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19839335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 19:07:24 来源:igfitidea点击:
Bootstrap Hide Modal After Delay
提问by scientiffic
I'm trying to hide a bootstrap modal after a delay (~3 seconds). I tried the following, none of which had any visible effect:
我试图在延迟(~3 秒)后隐藏引导模式。我尝试了以下方法,但都没有任何明显的效果:
$(".embedModal").delay(3000).modal('hide');
setTimeout($('.embedModal').modal('hide'),3000);
How can I add a short delay before hiding the modal?
如何在隐藏模态之前添加一个短暂的延迟?
回答by Nathan Harkenrider
Try wrapping the call to modal in a function.
尝试将调用包装在一个函数中。
setTimeout(function() { $('.embedModal').modal('hide'); }, 3000);

