JSFiddle - React, Tailwind, and code Playground

by Emily Humphrey

HTML

<button id="button">click me</button>

JavaScript

// Create the event.
var event = document.createEvent('Event'),
    elem = $("#button");
console.log(elem)
// Define that the event name is 'build'.
event.initEvent('build', true, true);

// Listen for the event.
elem[0].addEventListener('build', function (e) {
  // e.target matches elem
}, false);

elem.on("click", function(){
    elem[0].dispatchEvent('build', function(e){}, false);
});
// target can be any Element or other EventTarget.