Alternative for nth-child for older IE browsers

前端 未结 4 1008
野趣味
野趣味 2020-12-06 08:36

Is there an alternative for targeting elements using nth-child() for older IE browsers?

Javascript (non-jquery) would suffice as well.

EDIT: Giv

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-06 08:42

    You can use jQuery's :nth-child() selector;

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

提交回复
热议问题