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

Microsoft attribute methods

Test x.clearAttributes()
Test y.mergeAttributes(x)

Creating attributes

Perform these tests in the order they appear in:
z = document.createAttribute('title'); alert(z)
z.value = 'Test title'; alert(z.value)
x.setAttributeNode(z)
Now go over the test element with your mouse, you should see the title 'Test title'.

hasAttribute()

Test alert(x.hasAttribute('align'))
Test alert(x.hasAttribute('class'))
Test alert(x.hasAttribute('ppk'))
Test alert(x.hasAttribute('onclick'))

hasAttributes()

Test alert(x.hasAttributes())
Test alert(a.hasAttributes()) (a is the h2 at the top of this page. It has no attributes)