DHTML Collections
DOM Level 1 Specification.
Retrieves a collection containing all the supported attributes of a given object.
[ collattributes = ] object.attributes |
[ oObject = ] object.attributes ( iIndex ) |
collattributes |
Reference to a zero based array of attributes applied to the object. |
oObject |
Reference to an individual attribute in the array of attributes assigned to the object. |
iIndex |
Required. Number specifying the attribute to retrieve. |
This collection does not include custom attributes assigned in script.
The following example shows how the attributes collection is used to iterate through all the supported attributes of a specified object, in this case the document BODY.
NOTE: The function returns a list of the attribute names, whether the attribute was explicitly specified or not in HTML or in script.
<script language="JavaScript">
<!--
function getAttribs ( ) {
var attribs = document.body.attributes;
var atts = "The BODY element has the following attributes:\n\n";
for ( a = 0; a < attribs.length; a ++ )
atts += attribs [ a ].nodeName + ", ";
alert ( atts.substring ( 0, atts.length - 2 ) );
}
//-->
</script>
Show me
Attribute Object