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=\
From the docs (my emphasis)
Matches all elements that are the nth-child of their parent or that are the parent's even or odd children.
You're currently selecting the parent, while you should be selecting children:
$("div.entry > div:nth-child(3)").css("margin", "0px");
nth-child also seems to be non-0 indexed. Keep that in mind if you're used to indexing at 0.
Try this selector:
div.entry > div.box:nth-child(3n)
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");
});