![]() |
VOOZH | about |
Given an HTML document and the task is to select an element by its className using AngularJS. The elements can be selected with the help of a class name using the document.querySelector() method that is used to return the first element that matches a specified CSS selector(s) in the document.
Approach: The approach is to use the element of className class1 that will be selected and its background color is changed to green, by using the document.querySelector() method.
Example 1: This example illustrates for selecting the element by its class name in AngularJS.
Output:
Example 2: In this example, the 2 elements of same class are selected and some of the CSS is changed.
Output: