const event = new CustomEvent('build', { detail: elem.datset.time });
To add more data to the event object, the
customEvent
interface exists and the detail property can be used to pass custom data.
// create a look event that bubbles up and cannot be canceled
const evt = new Event('look',{
bubbles: true,
cancelable: false });
document.dispatchEvent(evt);
// event can be dispatched from any element,
// not only the document
myDiv.dispatchEvent(evt);