Mouse hover to change style

Description

The following code shows how to use Mouse hover event to change style.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<style type='text/css'>
.red {<!--from   w w  w  .j a v a2s.c  o m-->
    background-color: red;
}

.italic {
    font-style: italic;
    color: black;
}
</style>
  
</head>
<body>
  <div ng-app>
    <div 
     class="italic" 
     ng-class="{red: hover}" 
     ng-mouseenter="hover = true"
     ng-mouseleave="hover = false">
         Hover me.
    </div>
</div>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities