英 [klɑ:s neim] ? 美 [kl?s nem] ?
類(lèi)別名
javascript className屬性 語(yǔ)法
作用:設(shè)置或返回元素的 class 屬性。
語(yǔ)法:bodyObject.className=classname
javascript className屬性 示例
<html> <head> <meta charset="UTF-8"> </head> <body id="myid" class="mystyle"> <script type="text/javascript"> x=document.getElementsByTagName('body')[0]; document.write("Body CSS class: " + x.className); document.write("<br />"); document.write("An alternate way: "); document.write(document.getElementById('myid').className); </script> </body> </html>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例