代码:
<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/