buttons A, B, C

browserevent ⟩ .target ⟩ example ⟩ buttons A,B,C

// register handler on parent
document.body.addEventListener("click", event => {
    // ⭐️ check if button is clicked
    if (event.target.nodeName === "BUTTON") {
        console.log(`🔘 button "${event.target.textContent}" clicked ...`);
    }
});

Last updated