运行 ❯
获取您的
自有
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 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>