1. Traversing all the controls in the face
Function FindControlAll ()
{{
var innputs = document.GetelementsBytagname ("Input");
for (j = 0; j <inputs.length; j ++)
if (inputs [j]. Type == "Text") // Here the controls of the page of the page as Text are found, and you can also set it to the control type you want to travel through
{{
inputs [j]. Value = ""; // Clear the content of the text box
}
}
2. Traversing controls in the specified container
Function FindControl ()
{{
// Table1 below refers to the control in the table
var innputs = document.GetelementByid ("table1").
for (var I = 0; I <inputs.length; i ++)
{{
if (INPUTS [I]. Type == "Text") // The same as above, the type and operation of the control can be filled in as needed
{{
inputs [i]. Value = "";
}
}
}
Obtain the parent container object
Copy code code as follows:
<div>
<input type = "Button" value = "Get the parent container object" onClick = "Checkboxall (this)"/>/>
</div>
Function Checkboxall (E) {
// Parentnode is to obtain superior attributes
var obj = e.parentnode.parentnode.parentnode.GetelementsBytagname ("*");}