4

I just noticed, its not necessary anymore in Chrome to select elements that have an id e.g with getElementById, you can directly call that element with its id name... e.g "para1" in this example:

<head>
  <title>getElementById Beispiel</title>
  <script>
    function changeColor(newColor) {
      para1.style.color = newColor;
    }
  </script>
</head>

<body>
  <p id="para1">Irgendein Text</p>
  <button onclick="changeColor('blue');">Blau</button>
  <button onclick="changeColor('red');">Rot</button>
</body>

is there any more specification on this? didn't find anything about it on the internet..

adiga
  • 31,610
  • 8
  • 53
  • 74
Marc_L
  • 2,826
  • 7
  • 37
  • 68
  • 1
    Internet Explorer introduced the notion of using "id" attribute values to implicitly create window properties way back in the 90s. It was a terrible idea then and it's a terrible idea now. – Pointy Jun 26 '20 at 12:32
  • Why was it terrible? – rfii Jan 15 '21 at 18:04

0 Answers0