The principle is to loop through the controls on the web page and then set the disabled attribute to true.
The code is as follows:
Copy the code code as follows:
<script type="text/javascript">
var nodeList = document.getElementsByTagName("input");
for (var i = 0; i < nodeList.length; i++) {
nodeList[i].disabled = true;
}
nodeList = document.getElementsByTagName("select");
for (var i = 0; i < nodeList.length; i++) {
nodeList[i].disabled = true;
}
nodeList = document.getElementsByTagName("textarea");
for (var i = 0; i < nodeList.length; i++) {
nodeList[i].disabled = true;
}
</script>
The following are the types of these controls:
It can be obtained through document.getElementsByName("controlName")[0].type.toLocaleLowerCase().
Depending on the control, there are the following types:
"text"
"textarea"
"select-one"
"select-multiple"
"radio"
"checkbox"