admin管理员组文章数量:1391981
I am using a simple popup for my site , Here's the below code, I want to show the popup after some interval of seconds,
Please help
<script type='text/javascript'>
$(function(){
var overlay = $('<div id="overlay"></div>');
overlay.show();
overlay.appendTo(document.body);
$('.popup').show();
$('.close').click(function(){
$('.popup').hide();
overlay.appendTo(document.body).remove();
return false;
});
$('.x').click(function(){
$('.popup').hide();
overlay.appendTo(document.body).remove();
return false;
});
});
</script>
I am using a simple popup for my site , Here's the below code, I want to show the popup after some interval of seconds,
Please help
<script type='text/javascript'>
$(function(){
var overlay = $('<div id="overlay"></div>');
overlay.show();
overlay.appendTo(document.body);
$('.popup').show();
$('.close').click(function(){
$('.popup').hide();
overlay.appendTo(document.body).remove();
return false;
});
$('.x').click(function(){
$('.popup').hide();
overlay.appendTo(document.body).remove();
return false;
});
});
</script>
Share
Improve this question
asked Apr 2, 2015 at 20:05
APEXAPEX
471 gold badge2 silver badges13 bronze badges
1
- 1 What you're probably looking for is javascript's setTimeout() function. As a friendly aside, you may want to get into the habit of formatting your code with proper indents - it's hard to read the structure as it is. – CodeMoose Commented Apr 2, 2015 at 21:03
2 Answers
Reset to default 2Wrap the line that shows your popup in a setTimeout like this:
setTimeout(function(){
$('.popup').show();
}, 5000);
You can use delay() method, e.g.:
$('.popup').delay(3000).fadeIn(100);
demo: http://jsfiddle/54pzpfp1/
本文标签: javascriptShow popup after some secondsStack Overflow
版权声明:本文标题:javascript - Show popup after some seconds... - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744680882a2619399.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论