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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
Spread Privacy
Spread Privacy
I
InfoQ
V
V2EX
S
Schneier on Security
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Latest news
Latest news
S
Secure Thoughts
Project Zero
Project Zero
MongoDB | Blog
MongoDB | Blog
I
Intezer
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
量子位
T
Threatpost
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
T
Tor Project blog
A
Arctic Wolf
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
L
LINUX DO - 热门话题

JS - 标签 - cywhat's blog

暂无文章

html简单实现button加载中且置灰不可点击
cywhat · 2021-09-09 · via JS - 标签 - cywhat's blog

简单js几行代码实现点击按钮,实现加载中,且置灰不可点击

1.html部分

1
2
3
4

<button id="Submit" type="button"
        class="btn btn-rounded btn-primary mb-6" value="获取验证码">
</button>

2.JS部分

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
function ClickBtnSms() {
    $('#Submit').click(function () {
        //按钮校验,disable = true不可点击 val里面的内容替换成你想实现的加载中/loading...等
        $('#Submit').val('加载中...').prop('disabled', true);
        $.ajax({
            url: "url", 
            type: "GET",
            data: {data: data},
            dataType: "JSON", // 将服务端返回的数据反序列化为字典
            success: function (res) {
                if (res.status) {
                    //这里放拿到res状态想要执行的函数
                } else {
                    //如果报错,需要恢复获取验证码的按钮
                    $('#Submit').val('获取验证码').prop('disabled', false);
                }
            }
        })
    })
}

关注一下再走吧

公众号 小程序

赞赏支持

微信打赏 支付宝打赏