Answers for "javascript custom events with data"

9

javascript custom events with data

//Listen for the event
window.addEventListener("MyEventType", function(evt) {
    alert(evt.detail);
}, false);

//Dispatch an event
var evt = new CustomEvent("MyEventType", {detail: "Any Object Here"});
window.dispatchEvent(evt);
Posted by: Guest on May-05-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language