5秒后加载 [英] Load after 5 seconds
本文介绍了5秒后加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以前从未这样做过。我想在加载页面5秒之后加载href's。
我正在编写一个脚本,但它不工作。
HTML:
< div id =div1> ;
< a id =singlehref =#>单曲播放< / a>
< a id =multihref =#>头对头< / a>
< / div>
JS:
$(window).load(function(){
function ahref(){
$(#div1)。show();
$;
window.setTimeout(ahref,5000); // 5秒
})
哪里出了问题?
解决方案
DEMO
b$ b
$(window).load(function(){function ahref(){$(#div1)。show();}; setTimeout(function ){ahref();},5000);}) #div1 {display:none;}
<脚本src =https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js>< / script>< div id =div1> < a id =singlehref =#>单曲播放< / a> < a id =multihref =#>头对头< / a>< / div>
Never done this before. I want to load an a href's after 5 seconds once the page has loaded.
I am working on a script but it is not working.
HTML :
<div id="div1">
<a id="single" href="#">Single Play</a>
<a id="multi" href="#">Head to Head</a>
</div>
JS :
$(window).load(function(){
function ahref(){
$("#div1").show();
};
window.setTimeout( ahref, 5000 ); // 5 seconds
})
Where have a gone wrong?
解决方案
DEMO
$(window).load(function() {
function ahref() {
$("#div1").show();
};
setTimeout(function(){ ahref(); }, 5000);
})
#div1{
display:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="div1">
<a id="single" href="#">Single Play</a>
<a id="multi" href="#">Head to Head</a>
</div>
这篇关于5秒后加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文