Jquery read-only and jqueryinput read-only

Source: Internet
Author: User

Jquery read-only and jqueryinput read-only

Everyone understands what this is. The normal syntax is as follows:


If (status = true ){
$ ("# MinDelistStr"). val (totalAmount); // remove "," from the header and write it to the item id string.
$ ("# MinDelistStr"). attr ("readonly", true );
}

However, on the internet, I saw someone say:


JQuery (

$ ("# Id "). attr ("readonly": "readonly"); // Add the readonly attribute & $ ("# ID "). attr ({readonly: 'true '});

$ ("# Id"). removeAttr ("readonly"); // remove the readonly attribute

);

This is not correct. At least I tried it on Firefox.



How does jquery make all form elements read-only $ ("form input"). prop ("readonly", true );
All Form Controls readonly all readonly ~
Note that buttons are included in the input selector ~
Input ~
Use the not Selector
$ ("Input: not (: button,: hidden)"). prop ("readonly", true );
Hope to help you ~
By Billskate
How does jquery make the checkbox read-only and read-only to the example code:

<Html>
<Head>
<Script type = "text/javascript">
Function disable ()
{
Document. getElementById ("check1"). disabled = true
}
</Script>
</Head>
<Body>

<Form>
<Input type = "checkbox" id = "check1"/>
<Input type = "button" onclick = "disable ()" value = "Disable Checkbox"/>
</Form>

</Body>
</Html>

Understand. Please ask if it is helpful. Remember to adopt it ~

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.