jQuery selector for first row of inline-block divs

后端 未结 4 1084
生来不讨喜
生来不讨喜 2021-02-11 06:24

I have some divs with display: inline-block; and I have to select first row of divs and set them for example different border color and I need to do it in javaScript (jQuery).

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-11 07:10

    You may use vanilla CSS Selector for this in jquery.
    Assuming that you have a grid of 3 X 3.

    $( ".container .item:nth-child(3n + 1)" ).css( "border-color","black" );

提交回复
热议问题