W3C DOM tests - the attributes[] array

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 the attributes[] array.

Other attribute tests:

Test scripts

Attribute list

The function call below creates a complete list of attributes, by index. This test is meant for determining the total number of attributes in the test element. Test does not work correctly in IE 5.5

createAttributeList()

attributes[index]

Does the browser support an indexed array of attributes?

alert(x.attributes[1]);
alert(x.attributes[1].name)

If so, how many attributes does it contain? Correct answer: 5, though Explorer usually has quite a few more.

alert(x.attributes.length)

attributes[key]

var test = x.attributes['align'];
alert(test);
alert(test.value);
var test = x.attributes['onclick'];
alert(test);
alert(test.value);
var test = x.attributes['style'];
alert(test);
alert(test.value);
var test = x.attributes['ppk'];
alert(test);
alert(test.value);
var test = x.attributes['class'];
alert(test);
alert(test.value);
var test = x.attributes['nonsense'];
alert(test);
alert(test.value);