jquery实现进度条状态展示

因项目需求要做状态展示,点击时进度条填满整个长度。实现此功能需下载jquery,文中给出了相关代码,旨在为有需要的人提供思路。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在这里插入图片描述
如上图所示,由于项目需要,需要做一个状态展示,当点击的时候填满整个长度,你需要下载jquery,代码如下:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .title-bar {
            width: 300px;
            height: 20px;
            margin: 0 auto;
            text-align: center;
        }

        .title-bar span {
            display: inline-block;
            width: 69px;
            font-size: 12px;
            cursor: pointer;

        }

        .title-bar span i {
            display: inline-block;
            border-radius: 10px;
            width: 5px;
            height: 5px;
            margin-bottom: 2px;
            margin-right: 4px;
        }

        .color-yellow {
            background-color: #FFCA25;
        }

        .color-blue {
            background-color: #3960FB;
        }

        .color-azury {
            background-color: #00D5FF;

        }

        .color-red {
            background-color: #FD1E60;
        }

        .total-bar {
            width: 900px;
            height: 15px;
            background-color: #ccc;
            margin: 20px auto;
            border-radius: 20px;
        }

        span {
            padding: 0;
            margin: 0;
            float: left;
        }

        .on-work {
            display: inline-block;
            width: 40%;
            height: 100%;
            background: #FFCA25;
            border-radius: 20px 0px 0px 20px;
        }

        .on-waite {
            display: inline-block;
            width: 20%;
            height: 100%;
            background: #3960FB;
        }

        .on-close {
            display: inline-block;
            width: 20%;
            height: 100%;
            background: #00D5FF;
        }

        .on-waring {
            display: inline-block;
            width: 20%;
            height: 100%;
            background: #FF2563;
            border-radius: 0px 20px 20px 0px;
        }

        .left,
        .right {
            float: left;
            margin-top: 20px;
        }

        .left {
            padding-left: 5px;
        }

        .right {
            float: right;
            padding-right: 5px;

        }
    </style>
</head>

<body>
    <div class="title-bar">
        <span class="work"><i class="color-yellow"></i>加工</span>
        <span class="waite"><i class="color-blue"></i>待机</span>
        <span class="close"><i class="color-azury"></i>关机</span>
        <span class="waring"><i class="color-red"></i>报警</span>
    </div>
    <div class="total-bar">
        <span class="on-work">
            <span class="left">8:00</span>
            <span class="right">9:00</span>
        </span>
        <span class="on-waite">
            <span class="left">9:00</span>
            <span class="right">12:00</span>
        </span>
        <span class="on-close">
            <span class="left">13:00</span>
            <span class="right">16:00</span>
        </span>
        <span class="on-waring">
            <span class="left">13:00</span>
            <span class="right">16:00</span>
        </span>

    </div>
</body>
<script src="./jquery.min.js"></script>
<script>
    $(function () {
        
        $('.title-bar').on('click', 'span', function () {
            var i = $(this).index();
            console.log(i);
            if (i == 0) {
                $('.on-work').show().css({ "width": "100%", "border-radius": "20px", "background-color": "#FFCA25", "z-index": "10" }).siblings().hide()
            } else if (i == 1) {
                $('.on-waite').show().css({ "width": "100%", "border-radius": "20px", "background-color": "#3960FB", "z-index": "10" }).siblings().hide()
            } else if (i == 2) {
                $('.on-close').show().css({ "width": "100%", "border-radius": "20px", "background-color": "#00D5FF", "z-index": "10" }).siblings().hide()
            } else if (i == 3) {
                $('.on-waring').show().css({ "width": "100%", "border-radius": "20px", "background-color": "#FD1E60", "z-index": "10" }).siblings().hide()
            }
        })

    })
</script>

</html>

希望可以给有需要的人提供思路。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月落星河°

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值