Natively JavaScript has the onclick
property to handle the event in question. Here you can read more about the property.
For a dynamically created button;
var boton = document.createElement("button");
boton.innerHTML = "click";
document.body.appendChild(boton);
boton.onclick = function() {
alert("Has hecho click");
};
And for an element of the DOM taking its ID;
var boton = document.getElementById("boton");
boton.onclick = function() {
alert("Soy un botón");
}
<button id="boton">Haz click</button>
In your case, if you are working with the attribute class
as in your example, if you have several buttons with the same class you should make a loop for
to go through all the elements with that class and apply the property;
var botones = document.getElementsByClassName("boton");
for (var i=0;i<botones.length;i++) {
botones[i].onclick = function() {
alert(this.innerHTML);
}
}
<button class="boton">Boton 1</button>
<button class="boton">Boton 2</button>
<button class="boton">Boton 3</button>
<button class="boton">Boton 4</button>