惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Last Watchdog
The Last Watchdog
博客园_首页
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
美团技术团队
小众软件
小众软件
V
V2EX
博客园 - Franky
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
Attack and Defense Labs
Attack and Defense Labs
S
Security Affairs
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
T
The Exploit Database - CXSecurity.com
有赞技术团队
有赞技术团队
S
Schneier on Security
人人都是产品经理
人人都是产品经理
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
K
Kaspersky official blog
PCI Perspectives
PCI Perspectives
AI
AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
O
OpenAI News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Register - Security
The Register - Security
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
博客园 - 【当耐特】
C
Cisco Blogs
大猫的无限游戏
大猫的无限游戏
Help Net Security
Help Net Security
Google DeepMind News
Google DeepMind News
S
Securelist
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
L
LangChain Blog
SecWiki News
SecWiki News
博客园 - 叶小钗
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V2EX - 技术
V2EX - 技术
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
L
LINUX DO - 热门话题
Cisco Talos Blog
Cisco Talos Blog

博客园 - 尘梦

calude code 2.188 根据cli.map还原 centos6 安装gcc 多版本 自定义编译bulma 神通mysql模式转 mysql ai数学书籍 chromedriver 网络安全渗透测试写法 编译php需要的扩展 python 合并同列数据 组合 新的excel vue table 表格记录选中 linux wktohtmlpdf 结合/tmp路径 无法创建问题 c语言开发 php扩展 sm4 macos php 如何链接神通数据库aci 使用c# 开发 php的com组件 世界级地图数据处理 及 联动效果 php 结合pcntl_fork导出excel数据 使用 python 部署chatglm2b macos 下连接php 人大金仓pdo_kdb问题 php curl 多次发送
layui table tr a标签倒计时 操作 刷新以后继续倒计时
尘梦 · 2024-05-21 · via 博客园 - 尘梦

结合localStorage

//开始计时

        startTimers=function(rowId,times){
            var buutons=$('#table-admin').next().find('tr[data-index="'+rowId+'"]').find("a[lay-event='send_datas']");
            buutons.addClass("layui-btn-disabled disabled-link");

            var countDown=times || 120;

            

            var timer = setInterval(function() {
                    countDown--;
                  
                    buutons.text("发送通知信息"+countDown)
                    if (countDown <= 0) {
                        localStorage.removeItem('timer_button_'+rowId)
                        buutons.removeClass("layui-btn-disabled").removeClass('disabled-link');
                        clearInterval(timer); // 倒计时结束,清除计时器
                        buutons.text("发送通知信息");
                        //取消数组
                        var table_send_index = JSON.parse(localStorage.getItem('table_send_index')) || [];
                        var indexid = table_send_index.indexOf(rowId);
                        if (indexid > -1) {
                            table_send_index.splice(indexid, 1);
                            localStorage.setItem('table_send_index', JSON.stringify(table_send_index));
                        }
                    }else {
                     
                        localStorage.setItem('timer_button_'+rowId,countDown);
                    }

                  

                }, 1000);
        }

···
...js
初始化加载
写在table的done里面
  var table_sends= JSON.parse(localStorage.getItem('table_send_index')) || [];

                for(var i=0;i<table_sends.length;i++) {
                    var timerss=localStorage.getItem('timer_button_'+table_sends[i]);
                    if (timerss) {
                        startTimers(table_sends[i],parseInt(timerss))
                    }
                }
...

事件加载
```js
 if (layEvent == 'send_datas') {

                //startTimers
                

                var data_index=$(tr).attr("data-index");

                //定义总的数据组
                var table_send_index= JSON.parse(localStorage.getItem('table_send_index')) || [];
                table_send_index.push(data_index);
                localStorage.setItem('table_send_index', JSON.stringify(table_send_index));
            

                startTimers(data_index,120);
}