HTML
<button type="button" class="btn" id="1">1</button>
<button type="button" class="btn" id="2">2</button>
<button type="button" class="btn" id="3">3</button>
JavaScript
window.addEventListener('DOMContentLoaded', ()=>{
document.querySelectorAll('.btn').forEach(x=>{
x.addEventListener('click',e=>{
console.log(x.textContent);
});
});
});
(Visited 1,019 times, 1 visits today)