开发者

Jquery- Show/hide image

开发者 https://www.devze.com 2023-03-16 16:16 出处:网络
on clicking the checkbox , an image should be displayed for 5 seconds and then it should hide.. $(\".isActive\").click(function() {

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

0

精彩评论

暂无评论...
验证码 换一张
取 消