I am looking to do something similar to jQuery’s eq() selector to target elements on a page based on their order. :nth-child() is exactly what I need except I want to target elements are are not children. For example:
<div></div>
<div></div>
If I wanted to target the 2nd div above, what can I use in css (without actually giving it an id or class)?
You cannot pick the nth element out of a set of arbitrary, unrelated matches with CSS selectors.
You can only do this in jQuery using
$('div:eq(1)').