simulate-dom-event可用于跨浏览器环境模拟DOM事件,仅适用于测试目的!
示例代码
<script src="index.js"></script>
<div id="t"></div>
<script>
var t = document.getElementById('t');
t.addEventListener('click', function(e) {
alert(e.which);
}, false);
window.simulateEvent(t, 'click', { which: 2 });
</script>
暂无评论