9 lines
230 B
TypeScript
9 lines
230 B
TypeScript
|
export default function triggerEvent(el, type) {
|
||
|
if ('createEvent' in document) {
|
||
|
// modern browsers, IE9+
|
||
|
const e = document.createEvent('HTMLEvents');
|
||
|
e.initEvent(type, false, true);
|
||
|
el.dispatchEvent(e);
|
||
|
}
|
||
|
}
|