Selectors API Level 1 and Level 2
The selectors allow you to select element nodes in the DOM tree by matching them against a group of selectors, and testing whether the element matches a particular selector. Using selectors makes searching and selecting complex elements faster.
You can use the querySelector() and querySelectorAll() methods to retrieve the element nodes. Both methods accept a single parameter, a string selector. The string selector is a selector or a group of selectors that can be surrounded by whitespace. If you use a selector group as the string selector with the querySelector() method, the method returns the first element (if any) that matches any of the selectors in the group.
The main features of the Selectors API Level 1 and Level 2 include:
- Selecting a single element
Use CSS Selectors to select a single element.
- Selecting multiple elements simultaneously
Select multiple elements using the querySelectorAll() method.
You can also create an accordion menu.