Jquery batch setting of readonly and disabled attributes

Source: Internet
Author: User

There are many ways to set attributes in batches. This article describes how to set the readonly and disabled attributes in batches using jquery.

The Jquery api provides a method to apply the disabled and readonly attributes to elements, which is recorded here. 1. the readonly code is as follows: $ ('input '). attr ("readonly", "readonly") // set the input element to readonly $ ('input '). removeAttr ("readonly"); // remove the readonly attribute of the input element if ($ ('input '). attr ("readonly") = true) // determine whether the readonly attribute has been set for the input element. There are two methods to set the readonly attribute for the element and cancel the readonly attribute: $ ('input '). attr ("readonly", true) // set the input element to readonly $ ('input '). attr ("readonly", false) // remove the readonly attribute of the input element $ ('input '). attr ("readonly", "readonly") // set the input element to readonly $ ('input '). attr ("readonly", "") // remove the readonly attribute of the input element 2. the disabled code is as follows: $ ('input '). attr ("disabled", "disabled") // set the input element to disabled $ ('input '). removeAttr ("disabled"); // remove the disabled attribute of the input element if ($ ('input '). attr ("disabled") = true) // you can determine whether the disabled attribute has been set for the input element. There are two methods to set the disabled attribute for the element and cancel the disabled attribute: the Code is as follows: $ ('input '). attr ("disabled", true) // set the input element to disabled $ ('input '). attr ("disabled", false) // The code for removing the disabled attribute of the input element is as follows: $ ('input '). attr ("disabled", "disabled") // set the input element to disabled $ ('input '). attr ("disabled", "") // remove the disabled attribute of the input element

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.