Home  >  Article  >  Web Front-end  >  JavaScript client traversing controls and obtaining parent container object sample code_javascript skills

JavaScript client traversing controls and obtaining parent container object sample code_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:05:081186browse

1, traverse all the controls in the surface
function findControlAll()
{
var inputs=document.getElementsByTagName("input");
for(j=0;j if(inputs[j].type=="text") //Here, find all the controls of type text on the page, you can also Set the type of control you want to traverse
{
inputs [j]. Value = "" "; // Clear the content of the text box
}
}
2 , traverse the controls in the specified container
function findControl()
{
// table1 below refers to traversing the controls in the table
var inputs = document.getElementById( "table1").getElementsByTagName("input");
for(var i=0;i {
if(inputs[i].type=="text" )//Same as above, the type of control and the operations to be done can be filled in as needed
                                                                                                                                                                                                                                  🎜>


Get the parent container object


Copy code