JSFiddle - React, Tailwind, and code Playground

by demee

HTML

<input type="button" value="OK" />
<input type="button" value="Cancel" />
<input type="button" value="Exit" />

JavaScript

var buttons = document.querySelectorAll('input[type=button]');

for(var i in buttons){ //buttons also contains "length" & "item" 
    if(buttons.hasOwnProperty(i)){
        buttons[i].addEventListener("click", function(){
            alert(buttons[i].value); 
        }, false); 
    }
}