DOM2 Reference |
[Back] | [Glossary] [Help] |
Source: | <div id="doc"> <div> Text in the first DIV. </div> <div id="DDD" class="secondClass"> Some text in the second DIV. </div> <div class="thirdClass"> Some text and <span id="SSS">element</span> in the third DIV. </div> <div class="fourthClass"> We can try <i>another elements</i>. It will be much more <b>interesting</b>. </div> <div> Text in the last DIV. </div> </div> |
---|
JavaScript: | var collection = document.getElementsByTagName('div'); var elem = collection[0]; var attr = collection[2].getAttributeNode('class'); elem.setAttributeNode(attr); var output = elem.getAttributeNode('class').value; |
---|
Output: |
|
---|
Remarks: |
|
---|