运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>The DOMTokenList Object</h1> <h2>The forEach() Method</h2> <p>The tokens in the list are:</p> <p id="demo" class="c1 c2 c3"></p> <script> let list = document.getElementById("demo").classList; let text = ""; list.forEach( function(token, index) { text += "Token " + index + "= " + token + "<br>"; } ); document.getElementById("demo").innerHTML = text; </script> </body> </html>