i’m trying to select the <a> within the <span> that’s the nth child of the <li>
HTML
<li>
<span><a></a></span>
<span><a></a></span>
......
<span><a></a></span>
</li>
jQuery
$(function(){
if ($('body').attr('class') == 'special') {
$('li span:nth-child(1) a').css({'color' : '#444444'});
};
});
what am i missing here because it doesn’t seem to select the <a>
thanks
Your code works, you can test it here, make sure of a few things:
What your code is running in a
document.readyhandler, like this:And that your anchors have an
hrefor anameattribute, otherwise the browser may render them as disabled, ignoring some styling.