Select All Elements On A Page
I am looking for a function in javascript which clicks on every element (links, buttons,...) on my page. All elements should be disabled by default. I am using this for my testing
Solution 1:
At first, get all elements on your page:
var elements = document.getElementsByTagName("*");
Now that you get them, make a mouse-event, make a loop and apply the event on every element:
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
for (var i=0; i < elements.length; i++)
{
elements[i].dispatchEvent (clickEvent);
}
Post a Comment for "Select All Elements On A Page"