javascript Chrome 控制台自动点击
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24109561/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Chrome Console Automatic Click
提问by dougieman97
I'm on a website that forces me to click numerous elements on the page
我在一个网站上,它迫使我点击页面上的许多元素
This is the code for the elements
这是元素的代码
<span class="icon icon-arrow-2"></span>
Is it possible to tell me the code to write into the console of google chrome to click all the elements on the page named "icon icon-arrow-2" at once?
是否可以告诉我写入谷歌浏览器控制台的代码,以一次单击名为“icon icon-arrow-2”的页面上的所有元素?
回答by Jivings
var items = document.getElementsByClassName('icon icon-arrow-2');
for (var i = 0; i < items.length; i++) {
items[i].click();
}
Or if there is jQuery on the page:
或者如果页面上有 jQuery:
$('.icon.icon-arrow-2').click();