Home >Web Front-end >JS Tutorial >Use javascript to disable all text boxes, drop-down menus, and multi-line text fields on the web page_javascript skills

Use javascript to disable all text boxes, drop-down menus, and multi-line text fields on the web page_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:09:051172browse

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 codeThe code is as follows:



The following are the types of these controls:

Can be obtained through document.getElementsByName("controlName")[0].type.toLocaleLowerCase().

There are the following types according to different controls:
"text"
"textarea"
"select-one"
"select-multiple"
"radio"
"checkbox"

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn