There are four elements that have name="test"
. This paragraph
is the first. This image is the next:
<ppk>
tag the fourth.
id="test"
(and not name
). It should
be ignored.This page contains test cases for getElementsByName()
.
Correct answers: 4 and 'P, IMG, INPUT, PPK' (in any order)
var x = document.getElementsByName('test'); alert(x.length); var writestring = ''; for (var i=0,test;test=x[i];i++) writestring += x[i].nodeName + ' '; alert(writestring);