xxxxxxxxxx
<button>1</button>
<button>2</button>
<button>3</button>
<script>
document.body.addEventListener("click", event => {
if (event.target.nodeName == "BUTTON") {
console.log("This button was clicked", event.target.textContent);
}
});
</script>
//ouput for clicking button 1: This button was clicked 1
//ouput for clicking button 2: This button was clicked 2
//ouput for clicking button 3: This button was clicked 3