Try it
Javascript
Jquery
Angular
Learn Angular
Learn Javascript
Learn Bootstrap
Learn jQuery
Ng-Focus-4
Example of
Ng-Focus
, in this we added class on focus and on blur. See the code below:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <style> .myFocus { background-color: lightgreen; } .blur { background-color: pink; } </style> </head> <body ng-app="app"> <div ng-controller="controllerName"> <div class="container"> Ng-Focus: <input class="form-control" type="text" ng-class="{true:'myFocus',false:'blur' }[focus]" ng-focus="focus=true" ng-blur="focus=false"> Focus: {{focus}} </div> </div> <script> var app = angular.module("app", []); app.controller('controllerName', ['$scope', function ($scope) { }]); </script> </body> </html>
Output
×
Save This try
Title
Description
<p>Example of <code>Ng-Focus</code>, in this we added class on focus and on blur. See the code below:</p>