JS control to set read-only and unavailable properties

Source: Internet
Author: User

This paper introduces several methods of JS to realize read-only:

To set the control to read-only, we need to know what does not readolny this property

I know that the checkbox and RadioButton do not have readolny this attribute, and I have already described how to set the checkbox to read-only in the previous article.

Today we just understand that universal controls are read-only and unavailable

document.getElementById (Textid). Disabled=true;
document.getElementById (textid). SetAttribute ("Disabled", true);

document.getElementById (Textid). Readonly=true;
document.getElementById (textid). SetAttribute ("readOnly", true);

The value of the first input becomes gray, and the color of the second input is displayed correctly.

Style modification

document.getElementById (Textid). Classname= "";

Supplemental Note: When the control is set to Disabled=true, JS is not getting the value of this control.

JS control to set read-only and unavailable properties

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.