JSFiddle - React, Tailwind, and code Playground

by chrispickford

HTML

<p id="element1">Element1</p>
<p id="element2">Element2</p>

JavaScript

(function() {
        var Site = {
            init: function() {
                this.bindEventHandlers();
            },
            bindEventHandlers: function() {
                for (var i=0; i<this.eventHandlers.length; i++) {
                    this.bindEvent(this.eventHandlers[i]);
                }
            },
            bindEvent: function(e) {
                e.$el.on(e.event, e.handler);
                console.log('Bound ' + e.event + ' handler for', e.$el);
            },
            eventHandlers: [
                {
                    $el: $('#element1'),
                    event: "click",
                    handler: function() { console.log('Clicked',$(this)) }
                },
                {
                    $el: $('#element2'),
                    event: "click",
                    handler: function() { console.log('Clicked',$(this)) }
                }
            ]
        };
        
        Site.init();
    })();