我正在使用twitter的bootstrap CSS框架(非常棒).对于一些给用户的消息,我使用警报Javascript JS和CSS显示它们.
对于那些感兴趣的人,可以在这里找到:http://getbootstrap.com/javascript/#alerts
我的问题是这个; 在我向用户显示警报后,我希望它在一段时间间隔后消失.基于twitter的文档和我看过的代码看起来像是没有出现:
有没有办法alert()自动关闭JavaScript ?
我有警报
alert("Error found");
Run Code Online (Sandbox Code Playgroud)
我想在几秒钟之后关闭它.这是可能的还是我应该去jQuery对话
我正在使用示例中的动态引导警报.见下文.
如何添加超时功能,以便在X时间后警报自动关闭?
HTML:
<div id="alert_placeholder"></div>
Run Code Online (Sandbox Code Playgroud)
JQUERY:
bootstrap_alert = function() {
}
bootstrap_alert.warning = function(message) {
$('#alert_placeholder').append('<div class="alert alert-block fade in"><button type="button" class="close" data-dismiss="alert">×</button><h4>Info!</h4>'+ message +'</div>');
}
bootstrap_alert.info = function(message) {
$('#alert_placeholder').append('<div class="alert alert-block alert-info fade in"><button type="button" class="close" data-dismiss="alert">×</button><h4>Info!</h4>'+ message +'</div>');
}
Run Code Online (Sandbox Code Playgroud)