Delay Div OnLoad

雨燕双飞 提交于 2019-12-24 01:47:10

问题


I have a div that I would like to delay onLoad for a set period of time using jQuery. Here is the code I have that isn't working:

$('#PriceBox').delay(8000).fadeIn(400); 

回答1:


CSS:

/** make sure the element is initially hidden */
​#PriceBox {
    display: none;   
}​

jQuery:

$(document).ready(function() {
    $('#PriceBox').delay(8000).fadeIn(400);
});
  • DEMO



回答2:


In order to do this you need to start off your div as display: none and then put the display code in a $(document).ready(..)

<div id="PriceBox" style="display: none">Delay load me</div>​

Javascript

$(document).ready(function() {
   $('#PriceBox').delay(1000).fadeIn(1000);  
});​

Fiddle: http://jsfiddle.net/6B6he/



来源:https://stackoverflow.com/questions/9672580/delay-div-onload

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!