JSFiddle - React, Tailwind, and code Playground
HTML
<form >
<input type="button" id='btn_0' class="btn" value="Btn1" />
<input type="button" id='btn_1' class="btn" value="Btn2" />
<input type="button" id='btn_2' class="btn" value="Btn3" />
</form>
JavaScript
var mensajes = new Array('Soy el boton 1','Soy el boton 2','Soy el boton 3');
$(".btn").bind("click",function(e){
var btn = this.id.split('_');
alert( mostrar_mensaje(btn[1]) );
});
function mostrar_mensaje(id){
return mensajes[id];
}