style.getAttribute() (Method)

A method to extract attributes from a style.


JavaScript - 1.5
JScript - 3.0
Internet Explorer - 4.0
Netscape - 6.0
Property/method value type:String primitive
JavaScript syntax:-myStyle.getAttribute(anAttribName)
-myStyle.getAttribute(anAttribName, aCaseSense)
Argument list:aCaseSenseA flag to indicate a case-sensitive lookup
anAttribNameAn attribute of a style object

This is an accessor method which is used to access named attributes of an Element object. Attributes are not properties in the strict sense of the word but may be accessible as if they were in some implementations.

This accessor is intended to provide a means of managing custom attributes.

You need to know the names of the attributes you want to access. If you do, then you can pass the attribute name as an argument to this method call.

The value of that attribute is returned by the method.

It would be logical to assume that attributes are named uniquely but if several share the same name, differing only in case-sensitivity, then if a case insensitive search is used you may not retrieve the one you expect. It is likely that you'll be given the last one that occurs but this may be implementation dependant.

The case-sensitive flag should be set to the Boolean true value to force a case-sensitive search and false to ignore the case of letters in the attribute name.

The following values can be passed in the optional case-sensitive flag argument:

The result will be the value of the attribute. If the element does not have an attribute of the specified name, a null value is returned.


See also:Element.getAttribute(), style.setAttribute()