javascript - nested ng-mouseover in angularjs doesn't work - Stack Overflow

I used the same approach with jquery which is the nested mouseover and mouseleave and it worked, but no

I used the same approach with jquery which is the nested mouseover and mouseleave and it worked, but not with angularjs.

I want to show the button when mouseenter into the <li>, but hide the button when the mouse touched the <p>. But the problem is my <p> is within the <li>.

<li ng-mouseover="showXBtn=true" ng-mouseleave="showXBtn=false">
  <p ng-mouseover="showXBtn=false" ng-mouseleave="showXBtn=true">Hide</p>

  <button ng-show="showXBtn"><span>x</span></button>
</li>

demo here :

I used the same approach with jquery which is the nested mouseover and mouseleave and it worked, but not with angularjs.

I want to show the button when mouseenter into the <li>, but hide the button when the mouse touched the <p>. But the problem is my <p> is within the <li>.

<li ng-mouseover="showXBtn=true" ng-mouseleave="showXBtn=false">
  <p ng-mouseover="showXBtn=false" ng-mouseleave="showXBtn=true">Hide</p>

  <button ng-show="showXBtn"><span>x</span></button>
</li>

demo here : http://plnkr.co/edit/66fxwmAJ3EZgpZql1yLP?p=preview

Share Improve this question edited Apr 28, 2014 at 3:55 Arun P Johny 388k68 gold badges531 silver badges532 bronze badges asked Apr 28, 2014 at 3:46 user3522457user3522457 2,9736 gold badges25 silver badges25 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Try using ng-mouseenter instead of ng-mouseover. Updated PLUNK

Try to stop the propagation of the event from p

<p ng-mouseover="showXBtn=false; $event.stopPropagation()" ng-mouseleave="showXBtn=true; test($event)">Hide</p>

Demo: Fiddle


Otherwise use mouseenter instead of mouseout

<li ng-mouseenter="showXBtn=true; test($event)" ng-mouseleave="showXBtn=false; test($event)">
    <p ng-mouseenter="showXBtn=false;" ng-mouseleave="showXBtn=true; test($event)">Hide</p>
    <button ng-show="showXBtn"><span>x</span></button>
</li>

Demo: Fiddle

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745398470a4625990.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信