Set the read-only property of the input box as readonly= "true" it's killing me. The following is true:
<class= "Inuptxt ac_input" type= "text" ID= "tt" name= "tt" readonly= "readonly">
Read-only property of the input box: readonly
When added as read-only in the page, you can add readonly= "readonly" directly in input, but if you want to change it by clicking the button, you need to do so via JS (or jquery).
The most recent use of this, finally found that the previous time to write this JS control why always so depressed, originally, JS in the ReadOnly, disabled and other property settings, there is a small bug (at least I think): First, document.getElementById ("id"). readonly = "true"; Set input to read-only, but when passed document.getElementById ("id"). readonly= "false" to remove the read-only attribute, there is no effect, at this time, you need to false outside the quotation marks to remove the JS statement to work properly.
Report:
1. jquery set and Cancel read-only properties by ID property
Set read-only: $ ("#id"). attr ("ReadOnly", "true");
Cancel Read-only: $ ("#id"). attr ("ReadOnly", false);//note false without quotation marks!!!
2. jquery bulk Set and cancel read-only properties
/* in the div with ID sa, all input boxes */
Set read-only: $ ("#sa input"). attr ("ReadOnly", "true");
Cancel Read-only: $ ("#sa input"). attr ("ReadOnly", false);
Thank you: 39154615
The following HelloWorld are written:
<Script> //Initialize the Voucherno text box$ (document). Ready (function () { varVoucherno= $("#voucherNo"); Voucherno.attr ("readOnly","true"); Voucherno.css ('Background-color','#DEDEDE'); }); //Voucherno Style functionChangestyle () {varPaymentmode= $("#paymentMode"). Val (); //$ ("#tt"). CSS (' Background-color ', ' #DEDEDE ');//no problem. varVoucherno= $("#voucherNo"); if(Paymentmode!='Geneva'){//no problem .voucherno.attr ("readOnly","true"); Voucherno.css ('Background-color','#DEDEDE'); } Else{voucherno.attr ("readOnly",false); Voucherno.css ('Background-color','#FFFFFF'); } }</Script>
JS Dynamic Control read-only property of the input box