Reputation: 560
I'm executing async code, so I wanted to trigger an event once I finished. I created Event object, and I want to pass my current "this" object as a target property of the event. However, this property do not change.
var e = new Event("success");
e.target = myTargetObject;
console.log(e.target); // return 'null' for any myTargetObject.
Upvotes: 3
Views: 2867
Reputation: 21532
var chngEvt = document.createEvent("MouseEvents");
chngEvt.initMouseEvent('click', true, true);
e.target.dispatchEvent(chngEvt);
Upvotes: 1