赞
踩
假装 input
假装 click js
文档:假装 input.note
链接:http://note.youdao.com/noteshare?id=e1891e5148477af542e0d26ebe7417ce&sub=EFC623169ED84EA7BEAA5B0C807A76B6
function fakeInput(inputElement) { // 假设有一个输入框 // const inputElement = document.getElementById('myInput'); // 创建一个input事件 const inputEvent = new Event('input', { bubbles: true, cancelable: true }); // 模拟触发input事件 inputElement.dispatchEvent(inputEvent); } // https://www.seaart.ai/fastTools // seaart_do_gen function doClick(dom) { // 创建一个自定义的点击事件 const clickEvent = new Event('click'); // 分发(触发)点击事件 dom.dispatchEvent(clickEvent); } function fakeInputVal(dom, val) { dom.value = val fakeInput(dom) }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。