Search notes:

DOM example: document.getElementsByTagName

document.getElementsByTagName('div') returns an array of nodes (a HTMLCollection) whose HTML element is <div>.
<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>getElementsByTagName</title>

  <script type="text/javascript">
    
     function main() { 
       try {
         var node_list = document.getElementsByTagName('body');

           node_list[0].innerHTML = "This is the body element";
     
       } catch(e) {alert (e);}
     }

  </script>

</head>
<body onload='main();'>
</body>
</html>
Github repository about-Document-Object-Model, path: /Node/Document/getElementsByTagName.html

See also

Two elements can be referenced more directly:
document.getElementById('…') returns the (single) element, if it exists, whose attribute id has a given value.
document.getElementsByName('abc') returns an array of elements whose name attribute is abc.
DOM examples

Index