In jquery, you can set an element in the page to be non-editable or triggered by jqueryobj.attr ("disabled", "disabled"), but the jquery API The reference does not indicate how to reset the elements of the page to disable to be triggered or editable.
It is found here that there are three workarounds to change the state of the element set to Disabled to Enabled.
The first: Change the Boolean state of the disabled, and the specific code and explanation are as follows:
Copy CodeThe code is as follows:
$ ("Button:eq (2)"). Click (function () {
var text2=$ ("Input:text:eq (2)");
if (text2.attr ("disabled") ==false) {
The third text input box disabled property is set to True by setting the Boolean property of disabled
Text2.attr ("Disabled", true);
}else{
Remove the disabled property by placing the third text input box disabled property to False
Text2.attr ("Disabled", false);
}
});
The second kind: Remove the disabled attribute, the specific code and explanation are as follows:
Copy CodeThe code is as follows:
$ ("Button:eq (1)"). Click (function () {
var text2=$ ("Input:text:eq (1)");
if (text2.attr ("disabled") ==false) {
Place the second text input box to disabled by setting the value of disabled
Text2.attr ("Disabled", "disabled");
}else{
Removes the Disable property of the second text input box by removing it
Text2.removeattr ("Disabled");
}
});
The Third Kind: Change the value of disabled, the specific code and explanation are as follows:
Copy CodeThe code is as follows:
$ ("Button:eq (0)"). Click (function () {
var text1=$ ("Input:text:eq (0)");
if (text1.attr ("disabled") = = "") {
or text1.attr ("disabled") ==false
Set the value of disabled to place the first text input box as disabled
Text1.attr ("Disabled", "disabled");
}else{
Clears the disabled property in the first text input box by overriding the
Text1.attr ("Disabled", "" ");
}
});
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<script type= "Text/javascript" ><!--
$ (document). Ready (function () {
$ ("Button:eq (0)"). Click (function () {
var Text1 = $ ("input:text:eq (0)");
if (text1.attr ("disabled") = = "") {
or text1.attr ("disabled") ==false
Set the value of disabled to place the first text input box as disabled
Text1.attr ("Disabled", "disabled");
} else {
Clears the disabled property in the first text input box by overriding the
Text1.attr ("Disabled", "" ");
}
});
$ ("Button:eq (1)"). Click (function () {
var Text2 = $ ("Input:text:eq (1)");
if (text2.attr ("disabled") = = False) {
Place the second text input box to disabled by setting the value of disabled
Text2.attr ("Disabled", "disabled");
} else {
Removes the Disable property of the second text input box by removing it
Text2.removeattr ("Disabled");
}
});
$ ("Button:eq (2)"). Click (function () {
var Text2 = $ ("Input:text:eq (2)");
if (text2.attr ("disabled") = = False) {
The third text input box disabled property is set to True by setting the Boolean property of disabled
Text2.attr ("Disabled", true);
} else {
Remove the disabled property by placing the third text input box disabled property to False
Text2.attr ("Disabled", false);
}
});
});
--></script>
<body>
<button>disabledNull</button>
<input type= "text" value= "input something into me!" size= "/>"
<br/>
<button>disabledRemove</button>
<input type= "text" value= "input something into me!" size= "/>"
<br/>
<button>disabledState</button>
<input type= "text" value= "input something into me!" size= "/>"
</body>
JS to change the disable of the drop-down box into a able method