W3C DOM tests - getElementsByName()

There are four elements that have name="test". This paragraph is the first. This image is the next:

The checkbox above is the third; and this <ppk> tag the fourth.

Finally, this div has id="test" (and not name). It should be ignored.

This page contains test cases for getElementsByName().

Test scripts


Correct answers: 4 and 'P, IMG, INPUT, PPK' (in any order)

var x = document.getElementsByName('test');
var writestring = '';
for (var i=0,test;test=x[i];i++)
	writestring += x[i].nodeName + ' ';