Get elements just 1 level below the current element by javascript

后端 未结 8 2005
自闭症患者
自闭症患者 2021-02-05 20:30

I need to access the DOM tree and get the elements just 1 level below the current element.

Read the following code:

8条回答
  •  感情败类
    2021-02-05 21:05

    I think node.childNodes is the right place to start. You could (to make it work with FF too), test the nodeName (and possibly nodeType) of all child nodes you get, to skip text nodes.

    Also you might have a look at some javascript library like prototype, which provide a lot of useful functions.

提交回复
热议问题