2

I want a selector for all children of an element on focus

I've tried the following and it didn't work

#myElement > * :focus { /*stuff*/}
000
  • 26,951
  • 10
  • 71
  • 101
Marcelo
  • 3,371
  • 10
  • 45
  • 76
  • 2
    You mean `#myElement:focus > * { /*stuff*/ }`? – Chad Jul 15 '13 at 19:31
  • @j08691 I'm customizing meganizr mega-menu. I want a certain drop-down to keep showing if there's any child on focus. For that, I want to add in the list of selectors to set the visibility of the dropdown this one I've described. – Marcelo Jul 15 '13 at 19:32
  • @Torr3nt I'm using actually. Instead of #myElement I'm using .myClass. Simplified it just for the question. – Marcelo Jul 15 '13 at 19:32
  • Oh, I think I understand what you're asking. If you're trying to change a parent's CSS based on a child, you won't have any luck. CSS is quite literally Cascading. It goes in a downward motion, and can't go back up in the hierarchy. – Chad Jul 15 '13 at 19:35
  • @Torr3nt: You'll be surprised to know that that's not actually what "cascading" means in terms of CSS. See http://www.w3.org/TR/CSS21/cascade.html – BoltClock Jul 16 '13 at 09:57

1 Answers1

0

focus only works with elements that accept keyboard input. try toggling a class from javascript based on events like "Focus" and "blur"

xionutz2k
  • 754
  • 3
  • 9