小编典典

较旧的IE浏览器的nth-child的替代

css

是否有替代方法可以将目标元素nth-child()用于较旧的IE浏览器?

Javascript(非jquery)也足够了。

编辑:不能将其他库添加到页面。


阅读 510

收藏
2020-05-16

共1个答案

小编典典

您可以使用jQuery的:nth-​​child()选择器;

$("li:nth-child(even)") // target even li's
$("li:nth-child(odd)") // target odd li's
$("li:nth-child(5n)") // target the fifth li
2020-05-16