The javascript client walks through the control and gets the parent container object sample code

  • 2020-03-30 01:12:20
  • OfStack

1. Iterate over all the controls in the plane
The function findControlAll ()
      {
              Var inputs = document. GetElementsByTagName (" input ");
              For (j = 0; J< Inputs. Length; J++)    
              If (inputs[j]. Type =="text"
            {   
                      Inputs [j]. Value = "";       // empty the text box
              }  
}
Traverses the control   in the specified container;
The function findControl ()
      {
              // table1 below refers to traversing the controls in the table
              Var inputs = document. GetElementById (" table1 "). The getElementsByTagName (" input ");
              For (var I = 0; I< Inputs. Length; I++)
              {
                      Inputs [I]. Type =="text")// as above, the type of control and the action to be done can be filled in as needed
                      {
                              Inputs [I] value = "";
                      }
              }  
        }

Gets the parent container object


<div >
<input type="button" value=" Gets the parent container object " onclick="CheckBoxAll(this)"/>
</div>
function CheckBoxAll(e){
//ParentNode  Is to get the parent property
var obj = e.parentNode.parentNode.parentNode.getElementsByTagName("*");}


Related articles: