04-04-2023, 07:35 AM
The HTML part between the <body></body> tags looks like this:
The JavaScript part looks like this:
Code:
<!-- Get elements by tag name -->
<div id="container">
<a href="https://nodejs.org/">Node.js</a>
<a href="https://openjsf.org/">OpenJS Foundation</a>
<a href="https://github.com/tc39">Ecma TC39</a>
</div>
The JavaScript part looks like this:
Code:
let links = document.getElementsByTagName('a');
document.write("<br>");
document.write('Link count: ', links.length);
document.write("<br>");
// Show the href of links
for(let i = 0; i < links.length; i++)
{
document.write(links[i].href);
}