请问: this.chlidren 在FF下怎么写?

ahuiok 2008-01-23 04:04:59
<div onclick="alert('childNodes:'+this.childNodes.length+'\nchildren:'+this.children.length);">
aaa<input type="button" value="bbb"/>ccc<input type="button" value="ddd" />eee
</div>


IE正常,FF下就报错 了
...全文
67 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ahuiok 2008-01-23
  • 打赏
  • 举报
回复
谢谢你.
mingxuan3000 2008-01-23
  • 打赏
  • 举报
回复

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">

<script>
HTMLElement.prototype.__defineGetter__("children",
function () {
var returnValue = new Object();
var number = 0;
for (var i=0; i<this.childNodes.length; i++) {
if (this.childNodes[i].nodeType == 1) {
returnValue[number] = this.childNodes[i];
number++;
}
}
returnValue.length = number;
return returnValue;
}
);
//alert("<div>"+a+"</div>")
</script>

</HEAD>

<BODY>
<div onclick="alert('childNodes:'+this.childNodes.length+'\nchildren:'+this.children.length);">
aaa <input type="button" value="bbb"/> ccc <input type="button" value="ddd" /> eee
</div>
</BODY>
</HTML>


一般的 这个情况你搜 children firefox 都有答案

87,915

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧