0

Do not judge strictly. This is a test code for training. I can not figure out why the last element of the ul tag does not appear by the getElementsByTagName

<!DOCTYPE HTML>
<html>

<head>
  <meta charset="utf-8">
</head>

<body>
  <div>Users:</div>
  <ul>
    <li>Max</li>
    <li>Daniel</li>
  </ul>
dsfsdf
  <script>
   var head = document.head.firstChild; // work good

   alert(head);

    var ul = document.body.getElementsByTagName("ul").lastChild; // undefined

    alert(ul);

  </script>

</body>

</html>

<!-- <script src="test.js"></script> -->
Sviat Kuzhelev
  • 1,758
  • 10
  • 28

0 Answers0