HTML DOM className 属性
定义和用法
The className property sets or returns the class attribute of an element.
语法
object.className=classname
实例
The following example shows two methods on how to get the class attribute for the <body> element:
<html>
<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>
输出:
Body CSS class: mystyle An alternate way: mystyle