[英]:nth-child() not work on li added with foraeach data-bind
Im making a single page app on codepen.io ( http://codepen.io/ntibbs/pen/ZbPPBm?editors=101 ) using knockout.js and jquery and while trying to figure out a way to select individual <li>
elements that are added to my page using a foreach binding I noticed I can not use :nth-child()
to do this. 我使用敲门js和jquery在codepen.io( http://codepen.io/ntibbs/pen/ZbPPBm?editors=101 )上制作了一个单页应用程序,同时试图找出一种选择单个
<li>
元素的方法使用foreach绑定添加到我的页面的代码,我注意到我不能使用:nth-child()
来做到这一点。 All the elements are considered :nth-child(1)
, not sure why its doing that. 所有元素都被认为是
:nth-child(1)
,不确定为什么要这样做。 Are there any ways I could select an individual <li>
element ? 有什么方法可以选择单个
<li>
元素?
The n in :nth-child()
represents the depth, not the order. :nth-child()
表示深度,而不是顺序。 So :nth-child(1)
selects every element that is the first child of its parent. 所以
:nth-child(1)
选择作为其父级的第一个子级的每个元素。
I'm not sure under what conditions you're trying to select a particular element, but I'll give you some options. 我不确定在什么条件下您要选择一个特定的元素,但是我会给您一些选择。
If you can give me some more info on that, I can edit this accordingly. 如果您可以提供更多有关此方面的信息,则可以进行相应的编辑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.