JSFiddle - React, Tailwind, and code Playground

HTML

<div id="output">TESTING</div>
<button id="button">Click me</button>

JavaScript

if(document.addEventListener)
{
    document.addEventListener('DOMContentLoaded', function() {

        // Click handler
        function myclick(ev) {
            document.querySelector("#output").innerHTML = "PASS";
        }
        
        // Generic handler.  Doesn't know about clicks but
        // can resolve the function from the ev.type string.
        function myfunc(ev) {
            fnname = "my" + ev.type;
            // Get the reference from the global scope
            fn = window[fnname];
            // Call the handler
            fn(ev);
        }
        
        // Copy the click handler reference to the global scope
        window['myclick'] = myclick;
        // Register the generic handler
        el_button = document.getElementById('button');
        el_button.addEventListener('click', myfunc, false);
    }, false);
}