简单的节点问题求教 你试一下这个或许就明白了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 不同, 属性也不会相同.... o3d中模型的问题 请问 这个网站(http://www.sinfors.com/cn)主体部分的FLASH是怎么做的,哪可以下载到 急啊 如何获得table当前行啊 谢谢 缺少对象错误 帮忙看下 谢谢了 请教mediaplayer和文件操作 jQuery这句 为什么我一个onchange事件不会执行? 急:如何知道动态变化表格的高度啊? 请问Set d = CreateObject("Scripting.Dictionary")有什么用呀!??????? jquery页面自动扩大倍率IE 请教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属性