最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery Show image for some time - Stack Overflow

programmeradmin3浏览0评论

On changing the select option i am displaying the image and on success of ajax call hiding that image .. but this happens very fast .. i want to display the image for some time say 2 seconds. how to do it

my code

 var div_id = $(this).closest('tr').find('.display_image').attr("id");
 $("#"+div_id).empty().html('<img src="${resource(dir:'images',file:'spinner.gif')}"/>');
 $("#"+div_id).show();

  $.ajax({
                type: "POST",
                url:"${createLink(controller:'s2PublicLifecycle',action:'UpdateField')}",
                data: dataString,
                success: function() {
                  $("#"+div_id).hide();
                }
              }); 

On changing the select option i am displaying the image and on success of ajax call hiding that image .. but this happens very fast .. i want to display the image for some time say 2 seconds. how to do it

my code

 var div_id = $(this).closest('tr').find('.display_image').attr("id");
 $("#"+div_id).empty().html('<img src="${resource(dir:'images',file:'spinner.gif')}"/>');
 $("#"+div_id).show();

  $.ajax({
                type: "POST",
                url:"${createLink(controller:'s2PublicLifecycle',action:'UpdateField')}",
                data: dataString,
                success: function() {
                  $("#"+div_id).hide();
                }
              }); 
Share Improve this question asked Jul 25, 2012 at 9:52 maazmaaz 3,66422 gold badges65 silver badges106 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

use jquery delay:

$("#"+div_id).delay(2000).hide(1);

Here's a jsfiddle

try setTimeout(function() { $("#"+div_id).hide(); }, 2000 );

发布评论

评论列表(0)

  1. 暂无评论