0

Go an LI holding an <A> - for the a:active state I want to change the CSS applied to the parent <LI> holding it... but I Cant work out the syntax in CSS....? Sure its a simple solution...?

<li><a href="#">link</a></li>
li { background-color: yellow; }
li a:active { color: red; }

Above makes the link red on mousedown, but how can I also make the background colour of the <li> red when <a> is in active state?

UPDATE - not possible in CSS. jQuery solution is below:

$('li a').mousedown(function(){
    $(this).parent().addClass('makeMeYellow');
});
dubbs
  • 1,167
  • 2
  • 13
  • 34
  • Not sure why this was downvoted but you can't do it with css (the clues in the name - cascading) there is no parent selector – Pete Feb 17 '22 at 14:38
  • Didn't think it was on reflection... will have to do it with jQuery – dubbs Feb 17 '22 at 14:40

0 Answers0