04-04-2023, 07:33 AM
The HTML part between the <body></body> tags looks like this:
The JavaScript part looks like this:
Code:
<!-- Select elements by class name -->
<div id="container">
<p class="note">The first note.</p>
<p class="note">The second note.</p>
<p class="note">The third note.</p>
</div>
The JavaScript part looks like this:
Code:
// Select elements by class name
let elements = document.getElementsByClassName('note');
for(let i = 0; i < elements.length; i++)
{
document.write(elements[i].innerHTML);
}