Sav*_*ant 1 html javascript button
我正在尝试点击带有的页面上的所有按钮class "btn btn-primary UnFollowUser"。
这是我尝试使用的脚本
var buttons = document.getElementsByName('UnFollowUser');
for(var i = 0; i <= buttons.length; i++)
buttons[i].click();
Run Code Online (Sandbox Code Playgroud)
但这引发了错误:
VM336:5未被捕获的TypeError:无法读取未定义(...)(匿名函数)的属性'click'@ VM336:5InjectedScript._evaluateOn @ VM158:878InjectedScript._evaluateAndWrap @ VM158:811InjectedScript.evaluate @ VM158:667
有任何想法吗?
您正在使用getElementsByName而不是 getElementsByClassName
var buttons = document.getElementsByClassName('UnFollowUser');
for(var i = 0; i < buttons.length; i++)
buttons[i].click();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5113 次 |
| 最近记录: |