How to simply solve the hand speed too fast, click the button too much, resulting in data submission multiple times

Source: Internet
Author: User

Recently, when debugging bugs, because of the boredom of leisure, I just submit data on the button above, I went crazy like many times click on the data, and I did not think that this system to me to build a lot of the same objects, we today's problems from this inside to explore:

For example, there is a button, <input type= "button" value= "Request" id= "appbtn" onclick= "return Submit ()" > Jump to the JS in Submit (), We can add the following code to this page

<script type= "Text/javascript" >
$ ("#appBtn"). Click (function () {
Let button not click again
$ (this). attr ("Disabled", "disabled");
Execute other code, such as submitting events, etc.
MyFunc ();
});

This appbtn is the ID of this button, then, you only click the first time effective, when you click on the first time, when clicked, he set this button to disabled, even if the speed behind you even faster, but you can not click the data, This solves the problem of submitting click multiple times

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.