标签: javascript
当你想选择第n个孩子时哪个更好或有什么区别?请注意我不想使用jQuery。
答案 0 :(得分:6)
嗯,你没有提供太多信息,但你有两种方法:
让node成为DOM节点:
node
node.childNodes[1]; //0 is the first child.
另一种方式......
node.querySelector(':nth-child(2)'); //in selectors, the first child has index 1.