简单的模拟网页按钮问题?
毕业设计
1
<div ><span>A</span></div> <div >积极情绪</div> <div ><span>A</span></div> <div >感谢/满意</div>
模拟点击这2个按钮,然后按CapsLock
模拟点击这2个按钮,然后点击
<div > <div id="js_submit_btn" >提交</div> </div>
帮忙给出这2中模拟按键
-
function dispatch(obj) { var e = document.createEvent('MouseEvents'); e.initEvent('click', true, true); obj.dispatchEvent(e); } function getEl(sel,text) { var arr = document.querySelectorAll(sel); for (var i = 0; i < arr.length; i++) { if (arr[i].innerText==text) return arr[i]; } } dispatch(getEl('.com-mark-pq-single-content','积极情绪')); setTimeout(function(){ dispatch(getEl('.com-mark-pq-single-content','感谢/满意')); }, 2000); setTimeout(function(){ dispatch(document.getElementById("js_submit_btn")); }, 4000);
-
function dispatch(obj) { var e = document.createEvent('MouseEvents'); e.initEvent('click', true, true); obj.dispatchEvent(e); } function getEl(sel,text) { var arr = document.querySelectorAll(sel); for (var i = 0; i < arr.length; i++) { if (arr[i].innerText==text) return arr[i]; } } dispatch(getEl('.com-mark-pq-single-content','积极情绪')); dispatch(getEl('.com-mark-pq-single-content','感谢/满意')); dispatch(document.getElementById("js_submit_btn"));
发表回复