我的弹出窗口使用 jQuery,它有一个关闭按钮。我想让关闭按钮在 30-60 秒后出现,并显示文字 "wait 60 seconds to close this window"
。现在是代码:
var shadow = $('<div id="shadowElem"></div>');
var speed = 1000;
$(document).ready(function() {
$('body').prepend(shadow);
});
$(window).load( function() {
screenHeight = $(window).height();
screenWidth = $(window).width();
elemWidth = $('#dropElem').outerWidth(true);
elemHeight = $('#dropElem').outerHeight(true)
leftPosition = (screenWidth / 2) - (elemWidth / 2);
topPosition = (screenHeight / 2) - (elemHeight / 2);
$('#dropElem').css({
'left' : leftPosition + 'px',
'top' : -elemHeight + 'px'
});
$('#dropElem').show().animate({
'top' : topPosition
}, speed);
shadow.animate({
'opacity' : 0.7
}, speed);
$('#dropClose').click( function() {
shadow.animate({
'opacity' : 0
}, speed);
$('#dropElem').animate({
'top' : -elemHeight + 'px'
}, speed, function() {
shadow.remove();
$(this).remove();
});
});
});
最佳答案
尝试(我假设dropClose
是关闭按钮的id)...
CSS
#dropClose {
display: none;
}
在打开弹出窗口代码
setTimeout(function() {
$("#dropClose").show();
}, 30 * 1000);
关于javascript - 使 jQuery 弹出关闭按钮延迟后出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27621334/