JSFiddle - React, Tailwind, and code Playground
by Ethan Hammond
HTML
<button id="myButton">
Button 1
</button>
<button id="myButton2">
Button 2
</button>
<button id="myButton3">
Button 3
</button>
JavaScript
var myFunctions = {
myButton: function(o){ alert("Button 1 pressed! (" + o +")"); },
myButton2: function(o){ alert("Button 2 pressed! (" + o +")"); },
myButton3: function(o){ alert("Button 3 pressed! (" + o +")"); }
}
function runBinds(binds){
for(bind in binds){
var myButton = document.getElementById(bind),
myCall = function(){
binds[bind]("Appended info");
};
myButton.addEventListener('click',myCall,false);
}
}
runBinds(myFunctions);