Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Statements</h1> <h2>The for Loop</h2> <p>Loop a NodeList and change the color of all p elements in the list:</p> <p>This is a p element</p> <p>This is a p element.</p> <p>This is a p element.</p> <script> const myNodelist = document.getElementsByTagName("P"); for (let i = 0; i < myNodelist.length; i++) { myNodelist[i].style.color = "red"; } </script> </body> </html>