显示全屏图像,等待2秒,关闭图像,打开div-javascript/jquery
我正在尝试打开全屏图像2秒钟,然后关闭图像。关闭图像后,将显示另一个元素显示全屏图像,等待2秒,关闭图像,打开div-javascript/jquery,javascript,jquery,image,Javascript,Jquery,Image,我正在尝试打开全屏图像2秒钟,然后关闭图像。关闭图像后,将显示另一个元素 $("#explosion-image").attr('src', %image_url%); $("#explosion-image").css({ height:'100%', width:'100%', position:'fixed', top:0, left:0 }); $("#explosion-image").show(); $("#explosion-image").delay(2000); $("#
$("#explosion-image").attr('src', %image_url%);
$("#explosion-image").css({
height:'100%', width:'100%', position:'fixed', top:0, left:0
});
$("#explosion-image").show();
$("#explosion-image").delay(2000);
$("#explosion-image").hide();
$("#explosion-image").attr('src', '');
$("#div-to-open").show();
此代码仅打开图像,而不执行任何操作:(
提前感谢您的帮助delay()
只对动画有效。您应该改用setTimeout
。即使它有效,您也需要链接调用:
$("#explosion-image").show().delay(2000).hide();
试试这把小提琴:
$("#explosion-image").css({
height: '100%',
width: '100%',
position: 'fixed',
top: 0,
left: 0,
display: 'none'
}).show()
setTimeout(function() {
$("#div-to-open").show();
$("#explosion-image").hide();
}, 2000)