I cant seem to click all of the class's
document.getElementsByClassName('node closed')[0].click();
This works but will only click on the first class, I need this to click all of the classes named 'node closed'
Thanks
I cant seem to click all of the class's
document.getElementsByClassName('node closed')[0].click();
This works but will only click on the first class, I need this to click all of the classes named 'node closed'
Thanks
[0]
means only the first element of the node list returned bygetElementsByClassName
.You have to do
getElementsByClassName
and iterate through all the matched elements like shown below:Working Demo
document.getElementsByClassName has some issues in IE
use jquery
just remove [0] and it will access all matched elements as [0] points to first element only.
iterate the result in a loop and assign click to each elements: