web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

jquery做一个横向百分比进度条(动态加载)

554 ℃
     

功能介绍:jquery做一个横向百分比进度条,数据从接口读取,实时刷新数据,进度条需要记住上一次的地方进行前后滑动,不能每次都从0开始加载。

具体代码如下:

html代码:

<div class="horizontal-percen">
  <span id="horizontal"></span>
</div>

css代码:

body{
  background: #77a5f1;
  display: flex;
  align-items: center;
  height: 100vh;
  justify-content: center;
}
.horizontal-percen {
   position: relative;
   margin: 79px auto;
   width: 280px;
   height: 20px;
   border-radius: 20px;
   background: white;
   overflow: hidden;
 }

.horizontal-percen span {
   position: absolute;
   width: 20%;
   height: 20px;
   border-radius: 20px;
   background: linear-gradient(to right, #fc770a, #ffd739);
   transition: all .5s;
 }

jquery代码:

let stripMeet = roundMeet = 100,
stripValue = roundValue = 20,
stripInterval = null,
roundInterval = null;

//进度条效果
let UpDataSpeed = (val, isStrip, isClear) = >{
  if (isStrip) {
    if (isClear) {
      window.clearInterval(stripInterval);
    }
    $('#horizontal').css('width', val + '%').find('b').text(val + '%');
  } else {
    if (isClear) {
      window.clearInterval(roundInterval);
    }
  }
};

//自动改变进度条
window.clearInterval(stripInterval);
stripInterval = window.setInterval(function() {
  stripValue = parseInt(Math.random() * stripMeet);
  UpDataSpeed(parseInt((stripValue / stripMeet) * stripMeet), true);
},
2000);

如何利用jQuery判断页面中是否存在某个class

jquery如何设置图片背景

jquery改变屏幕大小时触发

jquery如何实现返回头部

jquery鼠标点页面出现水波纹特效

标签: jquery知识, 百分比进度条

上面是“jquery做一个横向百分比进度条(动态加载)”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_3267.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > js
本文共计1059个字,预计阅读时长8分钟
生活小工具,收录了80多款小工具
上一篇: 推荐一款完全免费的 Windows 软件卸载、清理工具——HiBit Uninstaller
下一篇: 推荐一款可免费商用圆体字库——江城圆体
x 打工人ai神器