开发者

How can I access every 5th Div, from a container so i can then use jQuery's add Class

开发者 https://www.devze.com 2023-02-06 18:17 出处:网络
Hey Everyone, Here\'s what i\'m trying to do.. i have div that will contain numerous other div (products in a shopping cart), say

Hey Everyone, Here's what i'm trying to do..

i have div that will contain numerous other div (products in a shopping cart), say up 50.

of these contained divs, i need to access every 5th div begging with 1, so it'd be div # 1, 6, 11, 16, 21 etc. and then use jQuery to Add Class to these di开发者_Python百科vs.

can someone point me in the right direction on how to do this?

it would be hugely appreciated, thanks


I think it will be useful:http://api.jquery.com/nth-child-selector/


$('div:nth-child(5n+1)).addClass('my-class');

0

精彩评论

暂无评论...
验证码 换一张
取 消