javascript - 5 秒后弹出 Bootstrap 模态窗口

标签 javascript twitter-bootstrap settimeout bootstrap-modal

有谁知道如何在 5 秒后弹出 bootstrap 模态窗口? 我已经完成了一个自动弹出的模式窗口,但我希望它弹出延迟 5 秒。 谁能帮忙? 感谢帮助 。 这是我的代码。

            <div class="modal fade in" id="formSaludo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: block;">
                <div class="modal-dialog">
                     <div class="modal-content">
                          <div class="modal-header">
                              <h5><strong>給我們一個小小的贊吧~我們會帶給你更多的趣事,新聞,最新動態!您的一個贊給我們帶來無限的力量!</strong></h5>
                              <img class="img-responsive center-block " src="funnylike.jpg">
                          </div> 
                          <div class="modal-body">
                            <div class="fb-like" data-href="https://www.facebook.com/cloudsblacks" data-width="200" data-layout="button_count" data-action="like" data-show-faces="true" data-share="false"></div>    </div> 
                            <div class="modal-footer">

                                  <a class="btn btn-link" data-dismiss="modal" style="font-size:15px;color:#808080;cursor: pointer;text-decoration: none;">已經讚了,请稍等...</a>
                          </div>  
                    </div>
                </div>
          </div>



   <!-- Modal Window -->           
<script type="text/javascript">
    $(window).load(function(){
        $('#formSaludo').modal('show');
    });
</script>   

最佳答案

使用setTimeout()函数

$(window).load(function(){
    setTimeout(function(){ $('#formSaludo').modal('show'); }, 5000);

});

关于javascript - 5 秒后弹出 Bootstrap 模态窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28137452/

相关文章:

javascript - 使用 div :title tag attribute instead of a:href attribute to toggle divs

javascript - 每 0.2 秒运行一次 mousedown 事件,直到鼠标松开

jquery - setTimeout、clearTimeout jQuery

jquery - CSS:对齐 DIV 中的元素

php - 在 localhost 中执行代码时,php 文件中的部分 html 文件没有出现

javascript - `setTimeout(func, 0)` 和 `setTimeout(func, 1)` 被认为是一样的吗?

javascript - 如果需要字段,请停止在表单提交上加载图像

javascript - 删除列不能与 jquery 一起正常工作

javascript - 将宽度更改为 100% 的 Google+ 嵌入式帖子

html - 相同高度列 bootstrap 3 行响应