对于某些元素执行click()不生效,采用模拟鼠标click事件
/**模拟click事件*/
function simulate_click(elem) {
if (document.createEvent) {
var e = document.createEvent("MouseEvents");
e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
elem[0].dispatchEvent(e);
} else if (element.fireEvent) {
elem[0].fireEvent("onclick");
}
}
posted on 2019-03-08 19:14 yemiaomiao 阅读(281) 评论(0) 编辑 收藏 举报