选择第n个子属性- children vs childNodes属性
Selecting an nth child - children vs childNodes property
当您想要选择第n个子时,哪个更好,或者有什么区别?请注意,我不想使用jQuery
你没有提供太多信息,但是你有两种方法:
设node
为DOM节点:
node.childNodes[1]; //0 is the first child.
的另一种方式…
node.querySelector(':nth-child(2)'); //in selectors, the first child has index 1.
相关文章:
- RegEx删除空属性?例如,如果(class=“”||class=“”)移除;否则就下课
- 全局变量和全局对象的属性之间有什么区别吗
- 如果使用 lodash 将属性存在于另一个对象中,则向对象添加属性
- 如何在Bootstrap Modal中为动态点击生成的变量设置jade属性
- 序列化数据属性中对象的最可靠方法
- 分析高度属性时出现意外值{{specs.height}}.index.html
- TypeError:无法读取属性'推'未定义的JavaScript
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- AngularJS-使用'true'属性
- 可以't使用JavaScript获取width属性
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 如何使用javascript获取嵌套对象中所有子对象的单个属性
- JavaScript Pub/Sub属性访问问题
- 从JavaScript访问struts操作中的属性
- 是否可以从父类访问子类的属性
- jQuery获取children元素的属性
- 如何获取children属性ID's在jsTree中
- 在指令中获取children属性
- 使用prototype's listeners属性的Listening children'的属性更改通知
- 选择第n个子属性- children vs childNodes属性