Select all class's with getElementsByClassName and click

后端 未结 5 1953
不思量自难忘°
不思量自难忘° 2020-12-10 00:19

I cant seem to click all of the class\'s

document.getElementsByClassName(\'node closed\')[0].click();

This works but will only click on th

5条回答
  •  感动是毒
    2020-12-10 00:49

    [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

    Working Demo

提交回复
热议问题