Selecting all Elements or Controls on a Page using Javascript.

vishalneeraj-24503
Posted by vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 245
Below code will return all controls which are visible on Page along with some hidden controls like event targets,hiddenfields as viewstates.
var elements = document.getElementsByTagName("*");
var str1 = '';
var counter = 0;

for (var i = 0; i < elements.length; i++)
{
str1 = str1 + '<br/>' + elements[i].id;
counter++;
}

div_1.innerHTML = str1 + '<br/> No. of controls: ' + counter;

<div id="div_1" style="border: solid 1px blue; width: 100%; height: 100%;"></div>

Comments or Responses

Login to post response