attributes Collection

DHTML, HTML, & CSS

attributes Collection


Retrieves a collection of attributes of the object.

Syntax

[ collAttributes = ] object.attributes
[ oObject = ] object.attributes(iIndex)

Possible Values

collAttributes 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. Integer that indicates the zero-based index of the item to be returned.

Members

Remarks

The attributes collection does not include expando properties. To access the expando properties of an object, use the JScript® (compatible with ECMA 262 language specification) for...in construct.

The attributes collection does not expose the style object. Use the cssText property of the object's style property to retrieve the persistent representation of the cascading styles associated with an object.

Unlike other DHTML collections, such as all and children, the attributes collection is static. Modifications to the properties of an object are not automatically reflected by an existing reference to the attributes collection of that object.

Example

This example shows how to iterate through the collection of attributes of the specified object, displaying the name and value of the attributes as well as the language of the attribute (HTML or script).

<SCRIPT>
function ShowAttribs(oElem)
{
    txtAttribs.innerHTML = '';

    // Retrieve the collection of attributes for the specified object.
    var oAttribs = oElem.attributes;

    // Iterate through the collection.
    for (var i = 0; i < oAttribs.length; i++)
    {
        var oAttrib = oAttribs[i];

        // Print the name and value of the attribute. 
        // Additionally print whether or not the attribute was specified
        // in HTML or script.
        txtAttribs.innerHTML += oAttrib.nodeName + '=' + 
            oAttrib.nodeValue + ' (' + oAttrib.specified + ')<BR>'; 
    }
}
</SCRIPT>

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
A, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BDO, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, HEAD, Hn, HR, HTML, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, NEXTID, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, XMP

Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.