javascript – jQuery在一定时间后删除bootstrap警报

我正在使用示例中的动态引导警报.见下文.

如何添加超时功能,以便在X时间后警报自动关闭

HTML

JQUERY:

bootstrap_alert = function() {
    }
bootstrap_alert.warning = function(message) {
    $('#alert_placeholder').append('
dismiss="alert">×dismiss="alert">×
最佳答案
创建一个删除一个(因此,最旧的)警报的函数

function alertTimeout(wait){
    setTimeout(function(){
        $('#alert_placeholder').children('.alert:first-child').remove();
    },wait);
}

[0]确保每次超时仅删除一个警报.

然后在显示警报时调用函数,参数是警报关闭时间长度,以毫秒为单位:

bootstrap_alert.warning = function(message) {
    $('#alert_placeholder').append('
dismiss="alert">×

请看这jsFiddle

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...