jquery - both mouseout and click off? -


i have drop down menu activated click - no problem. when mouseout closes - no problem. want close when click menu item - problem.

when click close, closes, move mouse re-toggles hidden class, presumably clashing mouseout.

i'm pretty new jquery please explain clearly.

the class 'visuallyhidden' visibility: hidden.

$body.on('click', 'a.user', function(e){       $('ul.user-links').toggleclass('visuallyhidden');   });    $body.on('click', 'ul.user-links', function(e){       $('.user-links').toggleclass('visuallyhidden');   });    $body.on('mouseout', 'ul.user-links', function(e) {       if($(e.toelement).parents('ul.user-links').length < 1) {         $('ul.user-links').toggleclass('visuallyhidden');       }   }); 

uhm , guess problem caused fact you're using toggleclass(); when click menu voice toggleclass() , when mouseout() toggleclass() again. try applying control on mouseout

if($('ul.userl-links').hasclass('visuallyhidden')){  .. }  else { } 

using addclass() , removeclass() instead of toggleclass() if make fiddle, i'll edit question answer better.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -