Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #custom #events #data
ADD COMMENT
Topic
Name
7+3 =