宝哥软件园

js实现定时进度条完成后切换图片

编辑:宝哥软件园 来源:互联网 时间:2021-09-06

定时进度条,进度100%以后可以切换图片等。

setInterval()和setTimeout()两个方法都可以实现。

源码:

!DOCTYPE html html标题元字符集='utf-8 '元http-equiv=' X-UA-兼容'内容=' IE=边'元名称=“视口”内容=' width=设备宽度,初始比例=1 '!- link href='favicon.ico' rel='快捷图标type=' image/x-icon '/link href=' fav icon。ico ' rel=' Bookmark '类型=' image/x-icon '/-meta name=' Generator '内容=' EditPlus ' meta name=' Author '内容=' meta name=' Description '内容=' title document/title link href=' rel='样式表/style type='text/css ' .进度{ border:1px固体# 000文本对齐:居中;高度:5px宽度宽度:500pxmargin:0 auto}。进度条{ background : # 000 height :5 px }/style script src=' http :http://apps。bdimg。com/libs/jquery/1。9 .1/jquery。量滴js '/script/head body div id=' class=' progress ' div id=' probar ' class='进度条/div H3 align=' center '/H3/div脚本类型=' text/JavaScript '/* * * * * * *方法一,setTimout()实现* * * * * * * * * * * */var p=0;var iidvar运行时=6000/100;//默认6秒函数GoCOunt(){ p;$('h3 ').html(p " % ");$('.进度条')。css('width ',p ' % ');if(p==100){ clearInterval(iid);警报('进度条满了,切换下一项.做某事');} } iid=setInterval(goCount,runtime);/******* 方法二,setTimout()实现* * * * * * * * * var p=0;var tidvar运行时=6000/100;函数GoCOunt(){ p;if (p=100) { //$(').进度条')。html(p " % ");$('.进度条')。css('width ',p ' % ');tid=setTimeout(goCount,runtime);} else { clear time out(tid);警报('进度条满了,切换下一项.');} } setTimeout(goCount,runtime);***************脚本/正文/html以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

更多资讯
游戏推荐
更多+