W3C DOM tests - attributes[]

Test elements

I gave the test element an event handler and an attribute I invented myself.

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

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

Test scripts

getAttribute()

Test alert(x.getAttribute('align'))
Test alert(x.getAttribute('ppk'))
Test alert(x.getAttribute('onclick'))
Test alert(x.getAttribute('style'))

And one with UPPER CASE attribute names:
Test alert(x.getAttribute('ALIGN'))
Test alert(x.getAttribute('PPK'))

getAttributeNode()

Test alert(x.getAttributeNode('align'))
Test alert(x.getAttributeNode('align').value)

removeAtribute()

Test x.removeAttribute('style')
Test x.removeAttribute('align')
Test x.removeAttribute('onclick')

removeAttributeNode()

Test x.removeAttributeNode(x.attributes['align'])
Test x.removeAttributeNode(x.attributes[1])

setAttribute()

Test x.setAttribute('align','right')
Test x.setAttribute('style','color: #00cc00') (correct behaviour: text becomes green and border disappears)
Test x.setAttribute('onclick','alert("Changed onclick")')
Test x.setAttribute('ppk','Noscript')