php - 如何在 3 秒后打开模式?

标签 php html css

代码:

<script>
   $(document).ready(function()
     {
       setInterval(function() 
         {
           $('#contact').modal();
         }, 3000);
     });
</script>

html代码:

<a href="#contact"><h4><i class="fa fa-phone"></i>Contact Us</h4></a>
<div id="contact" class="modalDialog">
<div> 
  <a href="#close" title="Close" class="close">X</a>
    <h2>Thanks For Visiting Us</h2>
    <form method="post">
      <input type="text" name="name" id="name" placeholder="Enter Your Name">
      <input type="text" name="email" id="email" placeholder="Enter Your Email">
      <input type="text" name="phone" id="phone" placeholder="Enter Your Phone">
      <input type="text" name="message" id="message" placeholder="Enter Your Message">
      <input name="captcha_code" type="text" value="" placeholder="Enter the code">
      <img src="captcha.php" id="capImage"/>
      <br/>Can't read the image? click here to  <a href="javascript:void(0);" onclick="javascript:$('#capImage').attr('src','captcha.php');">refresh</a>.
      <input type="submit" name="insert" id="insert" value="Submit" placeholder="Enter Your Message" >
  </form>
</div>

我希望页面加载后 3 秒模态将打开。在这里,我在 3 秒后使用 setinterval 方法打开模式,但它不能。那么,如何使用 setinterval 方法在 3 秒后打开模态?

谢谢

最佳答案

首先要确保你已经包含了 bootstrap.min.js

更改此 html

    id="contact" class="modalDialog"    

    id="contact" class="modal"    

当您使用 .modal() 函数时,该模型的主类应该是“modal”。 您的脚本函数工作正常,只需更改类即可。

关于php - 如何在 3 秒后打开模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43423453/

相关文章:

php - 是否可以在另一个中使用一个 php 扩展的功能?

html - Live Audio Streaming 到浏览器的方法,一定很简单

html - 带有 CSS 的多行文本背景颜色会截断字符

html - 为什么转换: translateX affect a fixed element's height on mobile?

asp.net - Chrome 和 Safari 中元素符号列表菜单的 CSS 渲染

php - 安装命令在 Composer 中不起作用

php - 检查网站宽度的最准确的自动化方法是什么?

php - 如何使 PHP for 循环倒计时而不是向上倒计时?

javascript - 如何仅使用 javascript 切换/切换 div onclick 的类

html - 是否可以使用 Google Cloud 限制对静态 html 网络文件的访问?