Home  >  Article  >  Web Front-end  >  AngularJS gets focus and manipulates focus

AngularJS gets focus and manipulates focus

php中世界最好的语言
php中世界最好的语言Original
2018-04-17 10:06:592532browse

This time I will bring you AngularJSGetting focus and operating focus. What are the precautions for AngularJS to get focus and operating focus. Here are practical cases, let’s take a look.

<!DOCTYPE html>
<html ng-app="formExample">
<head>
  <meta charset="UTF-8">
  <title></title>
  <script src="../js/angular.js"></script>
  <script>
    angular.module('formExample', [])
        .controller('FormController', ['$scope', function($scope)
        {
          $scope.userType = 'guest';
          $scope.change = false;
        }]);
  </script>
</head>
<body>
<form name="myForm" ng-controller="FormController">
  userType: <input name="input" ng-model="userType" ng-blur="change=true" ng-focus="change=false" required>
  <span class="error" ng-show="myForm.input.$error.required && change">必填项</span><br>
</form>
</body>
</html>

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to set the BootStrap title to prohibit crossing lines

js controls the time to move every second

parabola.js implements parabola and add to shopping cart functions

The above is the detailed content of AngularJS gets focus and manipulates focus. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn