Skip to content

Instantly share code, notes, and snippets.

@picacure
Last active December 22, 2015 06:38
Show Gist options
  • Save picacure/6432374 to your computer and use it in GitHub Desktop.
Save picacure/6432374 to your computer and use it in GitHub Desktop.
Event
var fireEvent = function (element,event){
var evt = document.createEvent('HTMLEvents');
// initEvent接受3个参数:
// 事件类型,是否冒泡,是否阻止浏览器的默认行为
evt.initEvent(event, true, true);
return !element.dispatchEvent(evt);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment