I have a selector, “td > a.leftmenuitem:last, div > a.leftmenuitem:last“, and I’d like to simplify it a little. I’ve tried “* > a.leftmenuitem:last“, “td, div > a.leftmenuitem:last“, and “(td, div) > a.leftmenuitem:last“, none of which work the way the first selector does. Is this kind of thing just not possible in the selector syntax without making a separate selector for each?
I have a selector, td > a.leftmenuitem:last, div > a.leftmenuitem:last , and I’d like
Share
You can’t simplify:
without there being something in common so you can select all relevant td and div elements with one expression. For example if they both had class blah you could do:
But do not use this kind of expression if you can avoid it. Class selectors are slow (compared to ID and tag selectors).
Is there something wrong with just?
?
By the way, are you certain
:lastis the correct choice? A lot of people mistakenly using it, mistaking it for:last-child.:lastwill only match one element, the last matching element found on the page.