当我在浏览器上打开网站时。现在我想通过每个浏览器都有的javascript控制台单击按钮。该按钮有类,并且网站不使用 jquery,因此代码将是纯 JavaScript。
document.getElementsByClassName('btn-orange').trigger('click'); document.getElementsByClassName('btn-orange').click();
感谢您抽出时间来帮助我。
最佳答案
document.getElementsByClassName('btn-orange')[0].click();
This will work, because document.getElementsByClassName('btn-orange') will give u an array of selected DOM elements, even if u have only one element with this classname, it will be on position first of the array, and then u call call click event on that element.
关于javascript - click() 函数不在任何浏览器控制台上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47164390/