Bootstrap the best way to implement a button that is disabled after a button is clicked _jquery

Source: Internet
Author: User

Bootstrap Click to disable the button and JS what is the difference between it and how to achieve it, today we will look at a click on the bootstrap to disable the button after the best way, the specific example below.

To prevent multiple submissions from clicking on the button in the bootstrap, you want to disable the button after clicking the button.

The implementation methods are as follows:

Disable button $ (' button '). addclass (' disabled '); Disables visually $ (' button '). Prop (' disabled ', true); Disables visually + functionally//Disable input button for button $ (' Input[type=button] '). addclass (' disabled '); Disables visually $ (' Input[type=button] '). Prop (' disabled ', true); Disables visually + functionally//Disable hyperlink $ (' a '). addclass (' disabled '); Disables visually $ (' a '). Prop (' disabled ', true); Does nothing $ (' a '). attr (' disabled ', ' disabled '); Disables visually writes the above method to the Click event, such as: $ (". Btn-check"). Click (function () {$ (' button '). addclass (' disabled ');//Disable S visually $ (' button '). Prop (' disabled ', true); 
Disables visually + functionally}); 
JS button clicks after a few seconds is not available: function timer (time) {var btn = $ ("#sendButton"); Btn.attr ("Disabled", true); button to stop clicking Btn.val (Time <= 0?) 
"Send dynamic Password": ("" + (Time) + "After seconds to send")); 
var hander = SetInterval (function () {if (time <= 0) {clearinterval (hander);//Clear Countdown Btn.val ("Send dynamic password"); 
Btn.attr ("Disabled", false); 
return false; }eLSE {Btn.val ("" + (time--) + "seconds to send"); 
}, 1000);  }//Call method Timer (30);

The above is a small set to introduce the Bootstrap button after clicking is disabled the best way to achieve the button, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.