Hi there,
Anyone use Kyle Fox modal plugin for jQuery? http://kylefox.ca/jquery-modal/examples/
I already use this extensively on a site and it is great but for the first time I need to launch one of the modals about 2 seconds after the page loads. All the documentation is click event based. Any ideas how I could achieve this?
Thanks!
Hey,
You can manually open a modal by calling the .modal()
method on an element. Combine this with setTimeout()
and you can achieve what you desire : )
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Kylefox modal</title>
<link rel="stylesheet" href="jquery.modal.css" type="text/css" media="screen" />
</head>
<body>
<div id="myDiv" class="modal">
<h1>Some awesome content!</h1>
<p>Hello!</p>
</div>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="jquery.modal.min.js" type="text/javascript" charset="utf-8"></script>
<script>
setTimeout(function(){
$('#myDiv').modal();
}, 2000);
</script>
</body>
</html>
1 Like
Thanks! That did it. Really appreciate the details!
system
Closed
August 13, 2015, 1:29am
4
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.