W3C DOM tests - attribute nodes

This is the first test element. It has the following attributes, in this order:
id="test"
align="center"
style="border: 1px solid #3B5F9B"
onclick="alert('Clicked!')"
ppk="JavaScript"

This is the second test element. It has only one attribute:
id="test2"

This page contains test cases for attribute nodes.

Other attribute tests:

Test scripts

getAttributeNode()

This method is supposed to return an attribute node, and not a value.

alert(x.getAttributeNode('align'))

The other tests request the value of the attribute node.

alert(x.getAttributeNode('align').value)
alert(x.getAttributeNode('onclick').value)
alert(x.getAttributeNode('style').value)
alert(x.getAttributeNode('ppk').value)

removeAttributeNode()

Reload the page after doing these tests; some attribute nodes that the other tests expect may be gone.

x.removeAttributeNode(x.attributes['align'])
x.removeAttributeNode(x.getAttributeNode('align'))
x.removeAttributeNode(x.attributes['style'])
x.removeAttributeNode(x.getAttributeNode('style'))
x.removeAttributeNode(x.attributes['onclick'])
x.removeAttributeNode(x.getAttributeNode('onclick'))

createAttribute and setAttributeNode

Perform this test and mouse over the main test element. The new title should appear.

var z = document.createAttribute('title');
z.value = 'Test title';
x.setAttributeNode(z);
alert(x.getAttribute('title'));