Reputation: 11
i want to show an image for a period of time after clicking a button and, while the image is showing, i want to hide the button. here is my code
function showimage(button, image, imagesrc){
$(button).click(function(){
if ($('img#'+image).length === 0) {
$('<img id=' + image + ' src=' + imagesrc + ' style={display: none;}>').insertBefore(button);
}
$(button).hide();
$('img#'+image).slideDown(500).delay(2000).slideUp(500);
$(button).show();
});
};
but show()
and hide()
won't follow the delay, what should i do?
Upvotes: 0
Views: 264
Reputation: 3777
You must use delay before show.
$(button).delay(500).show(0);
$(button).delay(500).hide(0);
Upvotes: 3