- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › sigh… can’t target child ul
Here is my code pen
http://codepen.io/seraphzz/pen/CAuie
I am trying to target the sub list so it will slidedown. Thanks for the help!
3 things you should do to make it work:
– select jQuery in your codepen — it’s currently not loading any JS library
– remove the submenu hover rule from your CSS
– remove the width:10px;
from your submenu LIs
Is there a way I can have it fallback to css if javascript is disabled?
You add from javascript a class to #nav (collapseMenu)
#nav:not('.collapseMenu') li { height:0; overflow:hidden; transition:height .1s }
#nav:not('.collapseMenu') li:hover { height:50px; transition:height .1s }
If javascript is disabled the menu does not have the collapseMenu class, so the css code will be activated.This doesn’t work in IE.
Update: Sorry, instead of li you put .sub-level and a greater height.
I was playing around with this as well and [this](http://codepen.io/David_Leitch/pen/ctAoI “http://codepen.io/David_Leitch/pen/ctAoI”) is what I came up with. As far as I can see, it should work with both javascript enabled/disabled, without the need for extra ids/classes.
Give the LI a class (‘fallback’) in the HTML.
Give the hover state under the fallback class in the CSS.
When JS is enabled, remove the fallback class. That way, the hover through CSS won’t be applied. And with JS not enabled, the hover through CSS will work fine.