0
我想显示一个html文件。然后淡入另一个。这是我的代码,它除了第一次,它等待10秒切换。然后在交换机之后,它在交换机之间等待5秒钟。我有点困惑,如何jQuery的处理超时和等待。我想每个开关等待5秒钟,从第一个开始。使用jquery加载一个html文件,延迟,然后另一个,循环
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#responsecontainer3").load("ad1.html");
var refreshId = setInterval(function() {
$("#responsecontainer3").fadeTo("slow").load('ad1.html?randval='+ Math.random());
setTimeout(function()
{
$("#responsecontainer3").fadeTo("slow").load('ad2.html?randval='+ Math.random());
}, 5000);
}, 10000);
});
</script>
<div id="responsecontainer3">
</div>
什么ad2.html ... –
@JoshBond检查更新答案” – thecodeparadox
@codeparadox:谢谢,它加载ad1.html但从来没有加载ad2.html。我将代码放在$(document).ready(function()中。 –