非常简单的问题 - (我希望如此!)
我有一个 div,在使用以下方法加载页面的其余部分之前不会显示:
<script>
function showDiv(){
var obj = document.getElementById('test');
obj.style.display = 'block';
}
</script>
在我的html的头部,以及正文中的以下代码:
<body onLoad="setTimeout('setTimeout(showDiv()', 1000);">
<div id="test" style="display:none;">
虽然 div 在设定的时间后正确加载,但我想知道是否有办法在给定的“超时”后淡入此 div,使用类似以下内容:
<script type="text/javascript">
$(function(){ // $(document).ready shorthand
$('#test').hide().fadeIn(1500);
});
</script>
例如?此刻,div 突然出现,尽管我希望让它以某种方式淡入。我曾尝试合并这两个js函数,但最终没有成功。非常感谢任何帮助或建议!
最佳答案
$(function(){
$('#test').hide();
setTimeout(function(){
$('#test').fadeIn('slow');
},1000);
});
关于jquery - showDiv() setTimeout 之后淡入 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7153369/