[英]setInterval calling function having setTimeOut
Initially moto
is hidden 10s;最初
moto
是隐藏的10s;
After 10s it should be visible. 10 秒后,它应该是可见的。
Stay visible - 15 sec.保持可见 - 15 秒。
Hide隐藏
and again:然后再次:
- hidden 10s... - 隐藏的 10 秒...
Here si my try, without success - moto
is never shown.这是我的尝试,但没有成功 -
moto
从未显示过。
function go_anima(){ $("#moto").hide(); setTimeout(function(){$("#moto").fadeIn();}, 10000); } $(document).on('ready', function(){ setInterval(function(){go_anima();}, 25000); });
.moto{display:none;}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class='moto' id='moto'>LOREM IPSUM</div>
There is no "ready" event 1 emitted by the document:文档没有发出“就绪”事件1 :
$(document).on('ready', function(){
Instead you need the ready
method :相反,您需要
ready
方法:
$(document).ready(function(){
Or, preferred, just:或者,首选,只是:
$(function(){
There is also
$(document).on( "ready", handler )
, deprecated as of jQuery 1.8 and removed in jQuery 3.0.还有
$(document).on( "ready", handler )
,从 jQuery 1.8 开始弃用并在 jQuery 3.0 中删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.