JavaScript Reference/Javascript Objects/attribute

Материал из Web эксперт
Перейти к: навигация, поиск

"attribute" Example

    
<html>
<body>
<input type="button" 
       value="Get the value of this button" 
       onclick="alert(this.attributes("value").value);">
</body>
</html>



"attribute" is applied to

Names noted with an asterisk (*) are JavaScript properties only.
+----------------+--------------------------------------------------------------+
| Applied_To     |attributes*                                                   |
+----------------+--------------------------------------------------------------+



"attribute" JavaScript collections

+----------------+--------------------------------------------------------------+
| JavaScript     |childNodes                                                    |
| collections    |                                                              |
+----------------+--------------------------------------------------------------+



"attribute" JavaScript Methods

+----------------+--------------------------------------------------------------+
| JavaScript     |appendChild                     cloneNode                     |
| Methods        |hasChildNodes                   insertBefore                  |
|                |removeChild                     replaceChild                  |
+----------------+--------------------------------------------------------------+



"attribute" JavaScript Properties

+----------------+--------------------------------------------------------------+
| JavaScript     |expando                         firstChild                    |
| Properties     |lastChild                       name                          |
|                |nextSibling                     nodeName                      |
|                |nodeType                        nodeValue                     |
|                |ownerDocument                   parentNode                    |
|                |previousSibling                 specified                     |
|                |value                                                         |
+----------------+--------------------------------------------------------------+



"attribute" Syntax and Note

Note:
An attribute of an element. 
You can only access the attribute object by referencing the desired index 
in the attributes collection.
    
Syntax:
    
document.all.elementID.attributes(index).memberName