jQuery :nth-child() selector

后端 未结 4 1006
春和景丽
春和景丽 2020-12-16 05:18

Hi please look at the HTML below. I am trying to use jQuery to get every 3rd instance on the DIVs with class=\"box\" contained within the DIV with class=\

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 05:53

    Your :nth-child selector does not reference n, and you need to reference the inner div in your selector.

    Try:

    $(document).ready(function(){
      $("div.entry div:nth-child(3n)").css("margin", "0px");
    });
    

提交回复
热议问题