我正在尝试使用 Chrome 控制台中的 JS 单击 Gmail 撰写对话框中的“关闭”按钮。该按钮有一个类“Ha”。类是静态的,刷新后不会改变。
截图
我尝试使用此代码,但没有任何反应:
document.querySelector(".Ha").dispatchEvent(new MouseEvent("mousedown"));
最佳答案
解决方案如下:
var test = document.getElementsByClassName("Ha")[0];
var e = document.createEvent('Event');
e.initEvent("mouseup", true, true);
test.dispatchEvent(e);
关于javascript - 使用 JS 或 jQuery 单击 Gmail 的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34835701/