![]() |
VOOZH | about |
The querySelector() method returns the first element that matches the specified Selector. It only gives one element from the HTML DOM if found else it returns null. To get all the matching elements, you can use the querySelectorAll() method.
// To search in complete documemt
ducument.querySelector(selectors);
// To search inside a specific element
element.querySelector("html-tag .class-name #element-id...");
selectors: It is a string containing the CSS Selectors.
Return value: The first element that matches the selectors if found else null.
Output: