執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
轉到 Spaces
<!DOCTYPE html> <html> <style> .myStyle { background-color: coral; padding: 16px; } .test { text-align: center; } .example { font-size: 25px; } </style> <body> <h1>The Element Object</h1> <h2>The className Property</h2> <div id="myDIV" class="myStyle test example"> I am a DIV element with multiple classes </div> <p>The class attribute of "myDIV" is:</p> <p id="demo"></p> <script> let value = document.getElementById("myDIV").className; document.getElementById("demo").innerHTML = value; </script> </body> </html>