0

Recently when I writing js code, I found something..

  1. I didn't define a variable which refers element using its id.
  2. And I gave an event to that id.
  3. It worked!!! without defining variable using "document.getElementById('id')"

For example :

html : 
<div id="abc"></div>

console :
abc;

console result :
<div id="abc"></div>

Why this happening? I didn't define variable 'abc' which refers div#abc.

ps. This happens not in ie. it happens in chrome.

goJson
  • 203
  • 2
  • 6
  • 12

1 Answers1

0

Getting an element using window[element id] or window[element name] is standard behavior implemented by all modern browsers since Firefox 14. See More

Community
  • 1
  • 1
Hamix
  • 1,323
  • 7
  • 18