Home>

angularjs ng-mouseenter directive

angularjs example

Execute the expression when the mouse pointer passes over the element:

<! Doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app="">
<div ng-mouseenter="count=count + 1" ng-init="count=0">mouse over me!</div>
<h1>{{count}}</h1>
<p>
This example automatically increments the count variable "count" when the mouse is over the div element.</p>
</body>
</html>

Definition and usage

The ng-mouseenter directive is used to tell the angularjs mouse what to do when the html element passes through.

The ng-mouseenter directive does not override the element's native onmouseenter event. When the event is triggered,Both the ng-mouseenter expression and the native onmouseenter event will be executed.

grammar

<element ng-mouseenter="expression"></element>

All html elements support this directive.

Parameter value

value description
expression An expression that is executed when the mouse passes over the element.

  • Previous RecyclerView click item setting event in Android
  • Next Solution to the conflict between ThinkPHP and UCenter