Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.

hovering over child elements firing mouseout

Comments

  • Registered Users, Registered Users 2 Posts: 12,023 ✭✭✭✭Giblet


    $('ul').on('mouseover','li',function(){
    var $li = $(this);
        if($li.find('div').size() == 0){
           
            $li.append('<div id="box"></div>');        
        }        $li.find('div').stop().animate({bottom:'0px'},{queue:false,duration:350});
    
        
    });
    $('ul').on('mouseout','li',function(){
     
        $(this).find('div').stop().animate({bottom:'-53px'},{queue:false,duration:300, 
    
          complete:function() {
    
          $(this).remove(); 
    
    
    }});}
    );
        
      
    


  • Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭Placebo


    Thanks Giblet, i got it functioning by using the evenlistener on the li instead, however i was just wondering why the img was firing the mouseout !

    Is there any speed issues with using find ?

    cheers


  • Registered Users, Registered Users 2 Posts: 12,023 ✭✭✭✭Giblet


    Placebo wrote: »
    Thanks Giblet, i got it functioning by using the evenlistener on the li instead, however i was just wondering why the img was firing the mouseout !

    Is there any speed issues with using find ?

    cheers

    More speed issues using jQuery in general. I've taken the li "off dom" to do the find operation, so it's quite fast.

    Image was firing mouseout as you were mousing in a sibling element, so the image moused out.
    #box{
    width:100px;
    height:50px;
    background:red; 
    position:absolute;
    bottom:-53px;
    z-index:9;
        -webkit-transition: bottom .4s ease-in-out;
        -moz-transition: bottom .4s ease-in-out;
        -o-transition: bottom .4s ease-in-out;
        -ms-transition: bottom .4s ease-in-out;
        transition: bottom .4s ease-in-out;
        
        
    }
    li:hover #box {
        bottom:0px;
        
    }
    
    

    Works too (#box would need to be on the dom, but could create a document fragment and append to the li without jQuery, or just have it there in your html) If you needed to support in older browsers, remove the animation and just have it display. I wouldn't do animations in older browsers anyway!


Advertisement