A method for manipulating hidden, disable, and other values in jquery _jquery

Source: Internet
Author: User
Generally we place some hidden attributes when implementing some form submission page

For example, when you modify a record, the ID of the record is embedded in the edit window

In the presentation interface, it is sometimes necessary to set the input or select Marquee to disable to avoid user modification

The hidden in the following code does not function properly in IE
Copy Code code as follows:

<input name = "Role_name" id = "Role_name" value= "Roy" disabled>
<input name = "role_id" id = "role_id" Hidden value= "3312" >

Standard wording should have added value
Copy Code code as follows:

<input name = "Role_name" id = "Role_name" value= "Roy" disabled = "Disabled" >
<input name = "role_id" id = "role_id" hidden = "hidden" value= "3312" >

Sometimes we need to edit the current page as above two, then what should be done?

We can use
Copy Code code as follows:

$ ("#role_name"). Removeattr ("Disabled");
$ ("#role_id"). Removeattr ("hidden");

Or
Copy Code code as follows:

$ ("#role_name"). Prop ("disabled", false);
$ ("#role_id"). Prop ("hidden", false);

Where $ ("#role_name"). Prop () returns a Boolean value that confirms whether this property has been turned on prop () method can also be used in checked options to control whether the option is selected

In general, prop () can be effective for writing property names and can be used for properties that use a Boolean control attribute state

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.