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

javascript - Hide 'div' after specific amount of time - Stack Overflow

programmeradmin3浏览0评论

I have a div, which is generally used for showing some status messsage like "you have selected some xyz thing"

Now, I need to hide it at interval of specific amount of time (say, 60 secs) after page loads.

Code:

 <div id="msg">You have selected 'Time and Money' magazine</div>

How can I perform the above mentioned thing?

Thanks

I have a div, which is generally used for showing some status messsage like "you have selected some xyz thing"

Now, I need to hide it at interval of specific amount of time (say, 60 secs) after page loads.

Code:

 <div id="msg">You have selected 'Time and Money' magazine</div>

How can I perform the above mentioned thing?

Thanks

Share Improve this question edited Jan 25, 2011 at 0:48 Justin Johnson 31.3k7 gold badges66 silver badges89 bronze badges asked Jan 19, 2011 at 5:23 I-M-JMI-M-JM 16k26 gold badges79 silver badges105 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 6
$(document).ready(function () {
  setTimeout(function () {
      $('#msg').hide();
  }, 60000);
});

To hide msg after 60 seconds, do this

$("#msg").fadeOut(60000);

This should do what you need: jQuery Timers

$(function(){
  $(document).oneTime(60000, function(){
    $('#msg').hide();
  });
});

you can use setTimeout this -

$('document').ready(function(){
  window.setTimeout('test()',time in milliseconds);
});

function test(){

  $('#divid').hide();

}

You can use jQuery's 1.4 delay function

发布评论

评论列表(0)

  1. 暂无评论