- 主题:js中如何判断A是否为B的子元素? (转载)
【 以下文字转载自 WebDev 讨论区 】
发信人: SJTUIT (consultant), 信区: WebDev
标 题: js中如何判断A是否为B的子元素?
发信站: 水木社区 (Tue May 27 14:04:37 2008), 站内
rt
--
FROM 218.81.109.*
var parent={
"a":111,
"b":false,
"c":null,
"d":{
"d1":123,
"d2":"aaa"
}
};
var son = parent.d;
for(var i in parent){
if(son == parent[i])
alert("equal");
}
【 在 SJTUIT (consultant) 的大作中提到: 】
: 【 以下文字转载自 WebDev 讨论区 】
: 发信人: SJTUIT (consultant), 信区: WebDev
: 标 题: js中如何判断A是否为B的子元素?
: ...................
--
FROM 219.224.98.59
说得不清楚
这里的元素指的是DOM元素
子元素是递归意义的
更准确地说法是子孙元素?
【 在 sly9 (弱) 的大作中提到: 】
: var parent={
: "a":111,
: "b":false,
: ...................
--
FROM 218.81.109.*
那就挨个找呗。。
遍历dom节点的childnodes。。
【 在 SJTUIT (consultant) 的大作中提到: 】
: 说得不清楚
: 这里的元素指的是DOM元素
: 子元素是递归意义的
: ...................
--
FROM 219.224.98.59
遍历parentNode会不会更好些。。
【 在 sly9 (弱) 的大作中提到: 】
: 那就挨个找呗。。
: 遍历dom节点的childnodes。。
--
FROM 144.214.46.*
re
【 在 GoddAmner (hello there, children) 的大作中提到: 】
: 遍历parentNode会不会更好些。。
--
FROM 218.81.109.*
哦对。。我脑残了。。
【 在 GoddAmner (hello there, children) 的大作中提到: 】
: 遍历parentNode会不会更好些。。
--
FROM 219.224.98.59
你是小神童,大犇犇。
【 在 sly9 (弱) 的大作中提到: 】
: 哦对。。我脑残了。。
--
FROM 144.214.46.*
先别急着奉承撒
parentNode怎么知道已经递归到顶了呢
【 在 GoddAmner (hello there, children) 的大作中提到: 】
: 你是小神童,大犇犇。
--
FROM 218.81.109.*
document就到顶了
【 在 SJTUIT (consultant) 的大作中提到: 】
: 先别急着奉承撒
: parentNode怎么知道已经递归到顶了呢
--
FROM 124.205.41.*