Get element by class name in AngularJs
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope) { $scope.getClassElm = function() { var element = angular.element(document.querySelector(".myPara")); element.css('color', 'blue'); }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <h3>AngularJs Is Cool!</h3> <p class="myPara"> This is test paragraph.... </p> <input type="button" value="Change Paragraph Color " ng-click="getClassElm()"> </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope) { $scope.getClassElm = function() { var element = angular.element(document.querySelector(".myPara")); element.css('color', 'blue'); }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <h3>AngularJs Is Cool!</h3> <p class="myPara"> This is test paragraph.... </p> <input type="button" value="Change Paragraph Color " ng-click="getClassElm()"> </div> </body> </html>
Copyrights@tutorialsplane.com