JSFiddle - React, Tailwind, and code Playground

by tobint

HTML

<script src="https://raw.github.com/tobint/jsSimple/master/event.js"></script>
<!doctype html>
<html lang="en-us">
<head>
    <meta charset="utf-8">
    <title>Event</title>
</head>
<body>
    Click Event.add() to add an event to the button.
    <div id="output"></div>

    <input type="button" id="add" value="Event.add(...)"/>
    <input type="button" id="remove" value="Event.remove(...)"/>
    <br/>
    
    Execute Event: <input type="button" id="execute" value="--no event--"/>

</body>
</html>

JavaScript

(function () {
    var a= document.getElementById("add");
    var r= document.getElementById("remove");
    var e= document.getElementById("execute");

    function sayHello() {
        alert("hello");
    }
    
    function addEvent() {
        Event.add(e, "click", sayHello, false);    
        execute.value = "sayHello()";
    }
    
    function removeEvent() {
        Event.remove(e, "click", sayHello, false);    
        execute.value = "--no event--";
    }
    
    Event.add(a, "click", addEvent, false);
    Event.add(r, "click", removeEvent, false);
    
}());