Home > Web Front-end > JS Tutorial > Detailed analysis of javascript traversal control instances_javascript skills

Detailed analysis of javascript traversal control instances_javascript skills

WBOY
Release: 2016-05-16 17:04:33
Original
1279 people have browsed it

js traverses page controls,

Copy code The code is as follows:

var inputArr = document.forms[0];
for( var i = 0; i < inputArr.length; i ) {
if( inputArr[i].type.toUpperCase() == "BUTTON" ) {
inputArr[i].disabled= "disabled";
}else if( inputArr[i].type.toUpperCase() == "FILE" ){
inputArr[i].readonly=true;
}
}

Another method:

Copy code The code is as follows:

var Elements = document.getElementsByTagName_r("*");
var msgs;
var i;
for ( i in Elements ) {
if ( Elements[i].type == "text" ) {
alert(Elements[i]. value);
}
}

JS traversal control value

Copy code The code is as follows:


JS traversal control value



"width: 100px">
: 100px">
 🎜>                                                                                                                          table>






Traverse the page text control code


Copy code

The code is as follows:
Function Texts ()
{
// var Els = Document.GetelementsBytagname ("*"); // Els get all the controls of the page
Var Els = ("Input "); //The above is also possible, which can reduce loops
                                                                                                                             els[i].type == "text" )
                                                                                                                                                                                                                                                                                      alert(msgs);
}


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template