JSFiddle - React, Tailwind, and code Playground

by SonickSeven

HTML

<body>
	<section class="content">
		<button id="btnAdd">Suma</button>
		<button id="btnSub">resta</button>
		<button id="btnDiv">división</button>
	</section>
</body>

JavaScript

function si(tag, cb){
	[].forEach.call(document.querySelectorAll(tag),function(elem) {
		cb(elem);
	});
}
//funcion que recorre TODOS los botones 
si('section.content>button' , function(elem){
    //se captura el evento click de todos los botnes que estan detro
    //de section.content
	elem.addEventListener('click', getId,false)
});
function getId(){
	var node=this;
    alert('el id del boton es: '+node.id);
}