1

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?

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
Praveen
  • 827
  • 6
  • 14
  • Instead of having to use "hacks" (formatting arbitrary text as code) to be able to post your question, why don't you include your simple example directly in the question itself instead of jsFiddle? See my edit. – Felix Kling Aug 20 '15 at 04:30

0 Answers0