当页面加载时,adiv
应该会出现 3 秒钟,然后自动消失。我现在遇到了代码问题。我在下面使用这个代码:
jQuery("#infor").delay(6000).fadeOut("slow");
我的 HTML 是:
<div id="infor">
something
</div>
但这似乎不起作用。有谁知道为什么这段代码不起作用?
Is your code within a document.ready
block?
$( document ).ready(function() {
$("#infor").delay(3000).fadeOut("slow");
});
It works for me: http://jsfiddle.net/YdU4z/
Your syntax appears to be correct (however if you wanted the delay to be for about 3 seconds, you should change the value inside the delay to 3000).
Do you have this code being wrapped within a document-ready block as seen below?
<script type='text/javascript'>
//Short-hand for $(document).ready()
$(function(){
//Delay for ~3 seconds and then fade out
$("#infor").delay(3000).fadeOut("slow");
});
</script>
I would try using the Developer Tools (F12) within your browser to see if any errors are being thrown (within the Console) and also ensure that the version of jQuery you are using supports the functions being called as well.