<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script language="JavaScript">
function test1() {
var node = document.getElementById("imgid2");
var pimg = node.parentNode.firstChild;
var inpu = node.parentNode.nextSibling;
alert(pimg.value);
alert(inpu.value);
}
</script>
</head>
<body>
<div>
<a id ="aid">
<img id ="imgid" value="img1" />
<img id ="imgid2" value="img2" />
</a>
<input type="text" value="input"/>
</div>
<input type="button" value="GOGO" onClick="test1();" />
</body>
</html>
//x下面的是我测试写的
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script language="JavaScript">
function test1() {
var node = document.getElementById("imgid2");
var pimg = node.parentNode.firstChild;
var pimg1=node.parentNode.childNodes[1];
var inpu = node.parentNode.nextSibling;
var iPar=node.parentNode.parentNode;
var inpu1=iPar.childNodes[0];
alert(pimg.value+"--"+pimg1.value);
alert(inpu.value+"--"+iPar.innerText+"--"+iPar.childNodes.length);
for(i=0;i<iPar.childNodes.length;i++)
{
alert(iPar.childNodes[i].value);
}
}
</script>
</head>
<body>
<div>
<a id ="aid">
<img id ="imgid" value="img1" /><img id ="imgid2" value="img2" /><img id ="imgid2" value="img3" /><img id ="imgid2" value="img4" />
</a>456
<input type="text" value="input"/>
<input type="text" value="input2"/>
<input type="text" value="input3"/>
<input type="text" value="input4"/>
</div>
<input type="button" value="GOGO" onClick="test1();" />
</body>
</html>