Javascript traversal page text control details

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

The following function implements a control ID that lists all HTML controls on the page of type text

        function Texts() 
             //var els= document.getElementsByTagName("*");   //els Gets all the controls for the page  
             var els= document.getElementsByTagName("INPUT"); //The top one is also ok, so you can reduce the loop
             var msgs=""; 
             for (var i=0;i<els.length;i++ )  
                 if (els[i].type == "text" )  
                     //Get control ID
                     msgs += els[i].id + ","; 

Related articles: