Jquery- Show/hide image
on clicking the checkbox , an image should be displayed for 5 seconds and then it should hide..
$(".isActive").click(function() {
开发者_StackOverflow社区 var checkBox_id = $(this).attr("id"); // id of checkbox
var div_id = $(this).closest('tr').find('.display_image').attr("id");
$("#"+div_id).empty().html('<img src="${resource(dir:'images',file:'spinner.gif')}"/>');
Blah.....Blah...
How to make change in code so that image will be displayed only for 5 seconds and then hide the image...
Add this after your code:
setTimeout(function(){
$("#"+div_id).empty();
}, 5000);
or you could change the middle line for:
$('#'+div_id).find('img').hide();
Use delay():
$( function(){
$('button').click( function(){
$('.image').fadeIn().delay(5000).fadeOut();
});
});
http://jsfiddle.net/WPDF9/
you can use
setTimeout("function name", 5000);
further here
精彩评论