Javascript 每15秒让酒吧爆满一次
我试着做一种加载条,我做了这个,但它不起作用。。。谁能帮助我Javascript 每15秒让酒吧爆满一次,javascript,jquery,Javascript,Jquery,我试着做一种加载条,我做了这个,但它不起作用。。。谁能帮助我 <div id="loader" style="height: 2px; width: 0px; background: green;"> Test </div> <script> $('#loader').animate({width:'100px'}, 15000); </script> 试验 $(#loader')。动画({宽度:'100px'},15000); 谢谢大家!
<div id="loader" style="height: 2px; width: 0px; background: green;">
Test
</div>
<script>
$('#loader').animate({width:'100px'}, 15000);
</script>
试验
$(#loader')。动画({宽度:'100px'},15000);
谢谢大家!
编辑:
这个有效
<div id="loader" style="height: 2px; width: 0px; background: green;">
</div>
<script>
$(document).ready(function(){
function loader(){$('#loader').animate({width:'0px'}, 1).animate({width:'468px'}, 15000, function() {loader()});}
loader();
});
</script>
$(文档).ready(函数(){
函数加载器(){$('#加载器')。动画({width:'0px'},1)。动画({width:'468px'},15000,函数(){loader()});}
加载器();
});
多亏了Pahnin,这对我很有用:
你确定加载的jQuery正确吗?:它适合我:
您确定正在正确加载包含jQuery的内容吗?:
加载文档后启动动画
$(document).ready(function(){
$('#loader').animate({width:'100px'}, 15000);
});
编辑:
上述函数用于在加载所有dom元素后运行jQuery代码,这也包括jQuery之类的库。
加载文档后启动动画
$(document).ready(function(){
$('#loader').animate({width:'100px'}, 15000);
});
编辑:
上述函数用于在加载所有dom元素后运行jQuery代码,这也包括jQuery之类的库。您的意思是:
function startLoad(){
$('#loader').animate({width:'100px'}, 15000);
setTimeout(function(){
$('#loader').css({'width':'0'});
startLoad();
}, 15000);
}
$(document).ready(startLoad);
你是说:
function startLoad(){
$('#loader').animate({width:'100px'}, 15000);
setTimeout(function(){
$('#loader').css({'width':'0'});
startLoad();
}, 15000);
}
$(document).ready(startLoad);
我看不到任何东西(没有绿色div)@Pekka他是说动画没有在写。我看不到任何东西(没有绿色div)@Pekka他是说动画没有在写。如果你想每隔15秒重复一次,你可以使用这个`函数startLoad(){$('#loader')。animate({width:'100px'},15000,function(){$('#loader')。css({'width':'0'));startLoad();});}$(文档).ready(startLoad)`如果你想每15秒重复一次,你可以使用这个函数startLoad(){$('#loader').animate({width:'100px'},15000,function(){$('#loader').css({'width':'0'});startLoad();}$(document).ready(startLoad)`