I mean instead of doing document.getElmentById('btn1')
I'm just doing this:
btn1.addEventListener('click', function() {
alert("btn1 clicked");
});
<button type="button" id="btn1">button</button>
How is this code working just fine?
I mean instead of doing document.getElmentById('btn1')
I'm just doing this:
btn1.addEventListener('click', function() {
alert("btn1 clicked");
});
<button type="button" id="btn1">button</button>
How is this code working just fine?