admin 管理员组

文章数量: 1086019

I have an unordered list where each li is a fixed small size but when you hover over it, it will expand to full size. This is done via ng-mouseover and ng-mouseout. The problem is that some of the li text contains other markup ( for example) and when the mouse enters the tag, it triggers a mouseout event and collapses the li.

Obviously the desired behavior is to have the li remain enlarged while the mouse is inside it, even if it's over a child element. Does anyone have an idea on how to basically ignore the mouseover of an inner element? I would also need to ignore the mouseout of the li if it were going into a child element.

I have an unordered list where each li is a fixed small size but when you hover over it, it will expand to full size. This is done via ng-mouseover and ng-mouseout. The problem is that some of the li text contains other markup ( for example) and when the mouse enters the tag, it triggers a mouseout event and collapses the li.

Obviously the desired behavior is to have the li remain enlarged while the mouse is inside it, even if it's over a child element. Does anyone have an idea on how to basically ignore the mouseover of an inner element? I would also need to ignore the mouseout of the li if it were going into a child element.

Share Improve this question asked Feb 26, 2013 at 21:21 SpencerSpencer 2,2453 gold badges28 silver badges50 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

There are two choices:

  1. Use CSS pointer-events on your inner elements (but first check how well it is supported in your target browsers).

  2. Use ngMouseenter/ngMouseleave instead (See this plnkr for different behavior between mouseenter/mouseleave vs. mouseover/mouseout)

本文标签: javascriptStop ngmouseenter and ngmouseout from triggering on inner elementsStack Overflow