2

I've noticed that I can use a to reference an element with an ID of "a" but I'm not sure if there's a name for this "method".

For example this would set the div's text to "b c".

<div id="a" class="b c"></div>
<script>a.innerHTML = a.classList</script>
Alexis Tyler
  • 1,394
  • 6
  • 30
  • 48

1 Answers1

2

It seems to be called Named access on the Window object by HTML5 standard. Read more here

The window object must have a property key whose value is elem if:

  • there is exactly one DOM element elem whose property id has the value key.

  • there is exactly one DOM element elem whose property name has the value key. elem’s tag must be one of: a, applet, area, embed, form, frame, frameset, iframe, img, object.

Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488