jquery定时器

jquery定时器| Id | Title | DateAdded | SourceUrl | PostType | Body | BlogId | Description | DateUpdated | IsMarkdown | EntryName | CreatedTime | IsActive | AutoDesc | AccessPermission |

| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------|
| 14592376| jquery定时器| 2021-03-29T14:54:00| | BlogPost|

复制代码


<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="../js/jquery.min.js"></script> <style> .active{font-size:16px;color:#ffffff; background: #000000;padding:10px;} </style> </head> <body> 数字从1变化到10:<div id="box1">0</div> 自动添加类:<div id="box2">0000000</div> 3秒后自动添加类:<div id="box3">0000000</div> <script> $(function () { fn1("#box1"); fn2("#box2"); //方法执行 setTimeout("fn2('#box3')",3000) //3秒后方法自动执行 }); function fn1(selector){ var num=0; timer=setInterval(function(){ num++; // alert(num) // var text="<span>"+num+",</span>" // $(selector).append(text); //节点添加 $(selector).text(num); if(num==10){ clearInterval(timer); //定时器清除; } },1000); }; function fn2(selector){ $(selector).addClass("active"); }; </script> </body> </html>
复制代码

 

| 648658| | 2024-04-29T20:50:00| false| | 2021-03-29T14:53:52.757| true| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="../js/jquery.min.js"></script> <style> .active{font-s| Anonymous|
posted @   RalphLauren  阅读(11)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示