I don't think this is possible in CSS, but in jQuery you would like to use filter() .
Make sure you filter based on contents() , not children() , since you want to see text nodes.
$( function() { $('li').filter( function() { return $(this).contents().first().is('a'); }).each( function() { $('body').append($(this).text() + '<br/>'); }); });
http://jsbin.com/olufan
It takes a bit more code than all this in the jQuery selector, but performance should be much better. JQuery selectors really work faster when specifying a single term.
source share