Set the disabled attribute to true in js and jquery to invalidate the button.

Source: Internet
Author: User

Set the disabled attribute to true in js and jquery to invalidate the button.

If the disabled attribute is set to true, It is unavailable.

JS

Document. getElementByIdx ("btn"). disabled = true;

Jquery

$ ("# Btn"). attr ("disabled", true );

Html

<Input type = "button" value = "Submit" id = "btn">

How to Use jQuery to add the disabled attribute to a button. After the button becomes grayed out, clicking this button can still trigger the event.

After the button is disabled, the event will not be triggered again.

Analysis should be caused by event bubbling. · check whether the parent element has a click event!
You can use e. stopPropagation (); To organize event bubbles ·

Come on ··

Invalid js control button

General process:
1. Get Button Object
2. Set the disabled attribute of the button object to true (disabled) or false (disabled)
Example:
ButtonObject = document. getElementById ('btnobj ');

ButtonObject. disabled = true;
 

Related Article

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.