I cant seem to click all of the elements.
document.getElementsByClassName('node closed')[0].click();
This works but will only click on the first element. I need this to click all of the elements with class 'node closed'.
Thanks
[0] means only the first element of the node list returned by getElementsByClassName.
You have to do getElementsByClassName and iterate through all the matched elements like shown below:
var el = document.getElementsByClassName('node closed');
for (var i=0;i<el.length; i++) {
el[i].click();
}
just remove [0] and it will access all matched elements as [0] points to first element only.
HTMLCollections returned by getElementsByClassName().