javascript - jQuery target parent of hidden element on hover (or not) -


i'm trying add class (or css) a, parent of hidden ul, shows when grand-parent li hovered.
can't change code directly result, need jquery.
code goes this:

html

<nav class="main-menu">   <ul>     <li>       <a>         <ul class="sub-menu"> 

css

.main-menu .sub-menu {display: none;} .main-menu li:hover .sub-menu {display: block;} .hovered {color: red;} 

and here i'm trying jquery, doesn't work:

jquery

jquery(".nm-main-menu ul.sub-menu).hover(function(){   jquery(this).parent().addclass("hovered"); }); 

here in fiddle.
maybe .hover() not way go...
please help.

jquery(".nm-main-menu ul.sub-menu").hover(function(){   jquery(this).parent().addclass("hovered"); }); 

you missed double quote inside selector. it's working.

fiddle: https://jsfiddle.net/gyowv1dx/1/


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -