javascript - click() 函数不在任何浏览器控制台上

标签 javascript google-chrome firefox console.log

当我在浏览器上打开网站时。现在我想通过每个浏览器都有的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/

相关文章:

css - 图标不显示在 mozilla firefox 中

javascript - Cloud Foundry 中的绑定(bind)服务不起作用

javascript - FindAndUpdate 如何检查文档是否真的更新了

javascript - 在 react 中使用javascript闰年 react 问题

javascript - 嵌套获取服务工作线程中的响应

javascript - Touch 上的全屏事件在 Chrome 上不起作用

google-chrome - Chrome 扩展写入文件系统

jquery - 国际域名 + JQuery attr ('href' ) Firefox 中的问题

python - WebDriverException : Message: Can't load the profile. 不知道发生了什么

javascript - 当登陆已经有一个 init 的路线/模板时,meteor-bootstrap-datetimepicker 会出现错误