基于Bootstrap5实现的响应式毫秒计时器秒表

所属分类: 网页特效-实用工具    2024-01-30 11:59:42

 41.1K  0  查看评论 (0)
基于Bootstrap5实现的响应式毫秒计时器秒表 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

基于Bootstrap5实现的响应式毫秒计时器秒表(共3个文件)

    • index.html

使用方法

let startTime;
        let accumulatedTime = 0;
        let running = false;

        function startStop() {
            if (running) {
                running = false;
            } else {
                startTime = null;
                requestAnimationFrame(updateTime);
                running = true;
            }
        }

        function reset() {
            accumulatedTime = 0;
            updateDisplay();
            running = false;
        }

        function updateTime(timestamp) {
            if (!startTime) {
                startTime = timestamp;
            }

            if (!running) return;

            accumulatedTime = timestamp - startTime;
            updateDisplay();

            requestAnimationFrame(updateTime);
        }

        function updateDisplay() {
            const totalMilliseconds = Math.floor(accumulatedTime);
            const days = Math.floor(totalMilliseconds / (24 * 60 * 60 * 1000));
            const hours = Math.floor((totalMilliseconds % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000));
            const minutes = Math.floor((totalMilliseconds % (60 * 60 * 1000)) / (60 * 1000));
            const seconds = Math.floor((totalMilliseconds % (60 * 1000)) / 1000);
            const milliseconds = totalMilliseconds % 1000;

            const timeString = `${formatTime(days)}:${formatTime(hours)}:${formatTime(minutes)}:${formatTime(seconds)}:${formatTime(milliseconds, 3)}`;
            document.getElementById('stopwatch').innerText = timeString;
        }

        function formatTime(value, digits = 2) {
            const paddedValue = value.toString().padStart(digits, '0');
            return paddedValue.substring(0, digits);
        }

        // Add event listener to stop the stopwatch on any touch
        $(document).on('touchstart', function () {
            running = false;
        });

        // Initial display
        updateDisplay();

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 实用工具

javascript带验证功能的PIN码在线生成器

鼠标可点击“生成Pin”按钮生成一个随机的4位Pin码,它将显示在input字段中。然后使用提供的数字按钮输入PIN。该代码还允许您清除输入的PIN,并提供输入的PIN是否与生成的PIN匹配验证提示。
  实用工具
 61220  0

jquery Base64编码和解码字符串base64.js

一款在线实时的编码解码工具插件,可以通过全局选项设置utf8编码和解码!
  实用工具
 9788  0

jquery在线eval加密/Encode加密插件

针对javascript脚本代码进行加密和解密,避免代码被copy复制盗用。
  实用工具
 11098  0

js在线检测打字速度和输入字符准确性实用工具

在线打字速度和准确度测试工具,其工作原理是在textarea中输入既定文本文字所需的时间,并将输入的文本文字和既定文本进行比较,如有不符textarea边框变为红色。
  实用工具
 5857  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论