HTML DOM className Property
Definition and Usage
The className property sets or returns the class attribute of an element.
Syntax
object.className=classname
|
Example
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>
|
Output:
Body CSS class: mystyle
An alternate way: mystyle
|
Try-It-Yourself Demos
Return the class attribute of the <body> element
 |

|
|
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today. |
|
|
|