JSFiddle - React, Tailwind, and code Playground
HTML
<button id="id1" >Button1</button>
<button id="id2" >Button2</button>
<script>
buttons = document.getElementsByTagName("button");
for( var x=0; x < buttons.length; x++ ) {
buttons[x].onclick = handleclick;
}
function handleclick()
{
alert(this.id); //here is your id
}
</script>