Read-only attribute of the input box: When readonly is directly added as read-only on the page, you can directly add readonly & quot; in the input box ;, but if you want to change it by clicking the button, you need to implement it through js (or jQuery.
Read-only attribute of the input box: readonly
When you directly add readonly = "readonly" to the page, you can directly add readonly = "readonly" to the input. To change the value by clicking the button, you must use js (or jquery).
The last time I used this, I finally found out why I was so depressed when I wrote this js control. Originally, when js set attributes such as readonly and disabled, there is a small bug (at least I think so): first, document. getElementById ("id "). readonly = "true"; set input to read-only. getElementById ("id "). readonly = "false" does not work when you remove the read-only attribute. In this case, you need to remove the quotation marks from the false field to the js statement for normal operation.
Appendix:
1. jquery sets and cancels read-only attributes through the id attribute
Set read-only: $ ("# id"). attr ("readOnly", "true ");
Cancel read-only: $ ("# id"). attr ("readOnly", false );
2. jquery batch set and cancel read-only attributes
/* All input boxes in p with id sa */
Set read-only: $ ("# sa input"). attr ("readOnly", "true ");
Cancel read-only: $ ("# sa input"). attr ("readOnly", false );
Related Articles:
Js sets the input text box to read-only
Set all form objects to read-only through js
Process the form to make input and other text boxes read-only and uneditable
The above is the details about using js to dynamically control the read-only attribute of the input box. For more information, see other related articles in the first PHP community!