PHP
·
发表于 5年以前
·
阅读量:8282
Element.prototype.trigger = function(type, data) {
var event = document.createEvent("HTMLEvents");
event.initEvent(type, true, true);
event.data = data || {};
event.eventName = type;
event.target = this;
this.dispatchEvent(event);
return this;
};
NodeList.prototype.trigger = function(event) {
[]["forEach"].call(this, function(el) {
el["trigger"](event);
});
return this;
};