通过dom穿越的问题 [英] problem traversing through dom

查看:85
本文介绍了通过dom穿越的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从特定元素中获取所有子元素的值

I am trying to get the values of all the child elements from a specific element

展开 | 选择 | Wrap | 行号

推荐答案

嗨...


您使用一种奇怪的方法来引用 node ...您真正想要引用哪个节点。 .. 桌子?还是div? ...可能在IE中表现不同?我认为IE也会计算表'的 tbody 所以使用固定计数器可能是一个问题...给应该引用id或特定类的节点以可靠地识别它们...


亲切的问候
hi ...

you use a strange method to refer to node ... which node do you really want to refer ... the table? or the div? ... may be it behaves different in IE? i think IE will count the table''s tbody too so it may be a problem to use a fixed counter ... give the nodes that should be refered an id or a specific class to identify them reliably ...

kind regards


我正在选择一个节点,然后固定次数遍历其父节点

,如果我在< span>< div>< div id =" myid">中选择带有myid的元素div

然后上升2次并且生病得到span元素。
来自该span元素的
我希望获得所有子节点

i am back跟踪来自我的div元素
well i am selecting a node and then traversing to its parent a fixed number of times
like if i select an element div with myid in <span><div><div id = "myid">
and then go up 2 times and ill get span element.
from that span element i want to get all the child nodes
i am back tracking to span from my div element


我这样做的主要原因是获取父元素的CSS样式

i无法控制top元素


i只有一个创建div的脚本,我想回溯固定数量的元素,然后从中获取每个子元素的所有css样式
the main reason i am doing this is to get the css styles of the parent elements
i dont have control of the top element

i just have a script that creates a div and i want to backtrack a fixed number of element and from then on get all the css styles of each child element


这篇关于通过dom穿越的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆