简单的节点问题求教 你试一下这个或许就明白了for(var i in sValue4){ alert(i);} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var sValue4 = oTR1.cells[0].firstChild;for(var i in sValue4){ alert(i);} 没有该属性...<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><!-- DW6 --><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>shawl.qiu template</title><style type="text/css">/* <![CDATA[ *//* ]]> */</style><script type="text/javascript">//<![CDATA[ if (navigator.appName=="Microsoft Internet Explorer") { //最大化窗口 self.moveTo(-5,-5) self.resizeTo(screen.availWidth +8,screen.availHeight+8) //这个脚本定义的宽度其实比原窗口还要大那么一点. }//]]></script><script type="text/javascript">//<![CDATA[ function fListMtd(obj, e){ if(!e)var e=window.event; var sur=e.srcElement||e.target; try{w.close();}catch(e){} w=open('','newwin','width=500,height=500,left=300,top=100,scrollbars'); w.document.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'); w.document.write('<style>body{width:400px;word-w.document.writeap: break-word;}</style>'); w.focus; w.document.ondblclick=function(){w.close();} fListMtd(obj, w); w.onload=function(){ w.document.title=sur.firstChild.data;}; w.document.close(); return true; function fListMtd(obj, target){ var ar=new Array(); var j=0; for(var i in obj){ try{ ar[j]=i.bold()+' '+(typeof obj[i]).fontcolor('red')+ ' '+(obj[i]+'').fontcolor('blue'); j++; }catch(e){ ar[j]=i.bold()+' '+(typeof obj[i]).fontcolor('red')+ (' empty').fontcolor('red').bold() j++; } } ar=ar.sort(); for(var i=0; i<ar.length; i++){ target.document.write(i+1,'. ',ar[i],'<br/>'); } return true; } } // end function fListMtd onload = function() { fListMtd(document.getElementById('a').firstChild, event); }//]]></script></head><body><div id="a">aaa</div></body></html> 楼上讲的小弟不是很明白,是不是firstChild后面只能有nodeValue不能跟innerText?谢谢 从var sValue4 = oTR1.cells[0].firstChild;for(var i in sValue4){ alert(i);}可以看出没有innerText这个属性,也就是说你得到的这个firstChild已经不是一个XML/HTML Element <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY><script language="javascript" type="text/javascript"> function getValue(){ alert(document.all.HYSBH.parentNode.parentNode.parentNode.lastChild.nodeValue); alert(document.all.HYSBH.parentNode.parentNode.parentNode.lastChild.innerText); } </script> <table> <tr bgcolor="#ffffff"> <td> <p><input type="radio" name="HYSBH" id="HYSBH" onclick="getValue();"/> </p><input type="text" name="projName" value="yy" ></td> <td id="p1"><p>2222</p></td> <td id="p2">3333</td> <td >4444</td> </tr> <tr> <td>okk</td> </tr> </table> </BODY></HTML>但在这里 alert(document.all.HYSBH.parentNode.parentNode.parentNode.lastChild.nodeValue); 为null alert(document.all.HYSBH.parentNode.parentNode.parentNode.lastChild.innerText);有值 第一为空第2个有值是怎么回事啊,这里有nodeValue属性 晕, 你用点书啃啃书吧...nodeType 不同, 属性也不会相同.... 下拉表单的怎么默认预选值 chrome在提交input type=file时,会出现“未选择文件” jquery滚动效果的问题 setInterval函数的格式问题,大家帮我一下。 getElementById的一点小问题 帮我看看下面的代码! 送分:如何用Javascript启动一个应用程序或加载一个动态链接库? 字符处理?多谢哦 你们喜欢哪种 【送分】一个简单的三级级联菜单问题 options对象 请教javascript联动问题 关于单击和双击的问题?
for(var i in sValue4)
{
alert(i);
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>shawl.qiu template</title>
<style type="text/css">
/* <![CDATA[ *//* ]]> */
</style>
<script type="text/javascript">
//<![CDATA[
if (navigator.appName=="Microsoft Internet Explorer") {
//最大化窗口
self.moveTo(-5,-5)
self.resizeTo(screen.availWidth +8,screen.availHeight+8)
//这个脚本定义的宽度其实比原窗口还要大那么一点.
}
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
function fListMtd(obj, e){
if(!e)var e=window.event;
var sur=e.srcElement||e.target;
try{w.close();}catch(e){}
w=open('','newwin','width=500,height=500,left=300,top=100,scrollbars');
w.document.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
w.document.write('<style>body{width:400px;word-w.document.writeap: break-word;}</style>');
w.focus;
w.document.ondblclick=function(){w.close();}
fListMtd(obj, w);
w.onload=function(){ w.document.title=sur.firstChild.data;};
w.document.close();
return true;
function fListMtd(obj, target){
var ar=new Array();
var j=0;
for(var i in obj){
try{
ar[j]=i.bold()+' '+(typeof obj[i]).fontcolor('red')+
' '+(obj[i]+'').fontcolor('blue');
j++;
}catch(e){
ar[j]=i.bold()+' '+(typeof obj[i]).fontcolor('red')+
(' empty').fontcolor('red').bold()
j++;
}
}
ar=ar.sort();
for(var i=0; i<ar.length; i++){
target.document.write(i+1,'. ',ar[i],'<br/>');
}
return true;
}
} // end function fListMtd
onload =
function()
{
fListMtd(document.getElementById('a').firstChild, event);
}
//]]>
</script>
</head>
<body>
<div id="a">aaa</div>
</body>
</html>
var sValue4 = oTR1.cells[0].firstChild;
for(var i in sValue4)
{
alert(i);
}
可以看出没有innerText这个属性,也就是说你得到的这个firstChild已经不是一个XML/HTML Element
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD> <BODY>
<script language="javascript" type="text/javascript">
function getValue()
{
alert(document.all.HYSBH.parentNode.parentNode.parentNode.lastChild.nodeValue);
alert(document.all.HYSBH.parentNode.parentNode.parentNode.lastChild.innerText);
}
</script> <table>
<tr bgcolor="#ffffff">
<td> <p><input type="radio" name="HYSBH" id="HYSBH" onclick="getValue();"/> </p><input type="text" name="projName" value="yy" ></td>
<td id="p1"><p>2222</p></td>
<td id="p2">3333</td>
<td >4444</td>
</tr>
<tr>
<td>okk</td>
</tr>
</table>
</BODY>
</HTML>但在这里
alert(document.all.HYSBH.parentNode.parentNode.parentNode.lastChild.nodeValue); 为null
alert(document.all.HYSBH.parentNode.parentNode.parentNode.lastChild.innerText);有值
第一为空第2个有值是怎么回事啊,这里有nodeValue属性