This property contains the name of the cascading style sheet class for the tag that the Element object represents. Because MSIE implements its tag objects so consistently as sub-classes of the Element object class, it is possible to apply CLASS tag attributes to tags that really shouldn't have style sheets associated with them. The <HTML> and <HEAD> tags for example. Nevertheless, you can still define a CLASS tag attribute and its value will be reflected and accessible in this property.
You can read or write this value to manipulate the style attributes of the object.
The value is specified as a String primitive, but is case sensitive. If you specify multiple items, they must be space separated.
Changing this value can be a way to change a whole range of style settings on an object in a single hit rather than modifying the individual settings one by one.
This property used to be called Element.class but has been renamed as of DOM level 1 to avoid namespace conflicts with a possible future object.class property.
This is not the name of the object class that is associated with the tag. In Netscape, you can usually figure out the class of an object by accessing the constructor property to get an object that represents the class and then you can obtain the name property of the constructor to find the class name. This doesn't work in MSIE in general. However, you can get a string version of an object in MSIE in many cases that is of the form "[object XXXXX]" where XXXXX is the class name. You will need to dismantle the string with a fragment of script.
There can be a conflict of style settings where the same attribute is controlled from several class settings. The following precedence rules are applied:
1. Styles defined in the Element's HTML tag.
2. Styles applied to the Element with the CLASS HTML tag attribute.
3. Styles applied using the ID value of an Element.
4. Inline styles defined within the script environment.
See also: | CLASS="...", Element object |
Prev | Home | Next |
Element.children[] | Up | Element.clearAttributes() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |