CSS/JQuery Hover Affect Only Hovered Element and Not Parent

后端 未结 5 1446
说谎
说谎 2021-01-26 11:07

I have a list of nested items, each which has it\'s own edit link.

5条回答
  •  不知归路
    2021-01-26 11:25

    If you want parent's .editlink to hide after you move from them to their children then you can use this:

    $('li').hover(
        function(e){
            e.stopPropagation();
            $(this).parents('li').trigger('mouseleave');
            $(this).children('.editLink').show();
        },
        function(e){
            e.stopPropagation();
            $(this).parents('li').trigger('mouseleave');
            $(this).children('.editLink').hide();
        }
    );
    

    DEMO

提交回复
热议问题