30 December 2022

The Vanilla JavaScript equivalent of jQuery's .find() method is the .querySelectorAll() method. The function allows us to search through the descendants of these elements in the DOM tree and construct a new jQuery object from the matching elements. So you won't get jQuery elemens as result of the JavaScript alternative, but you will get DOM elements instead.

Source code viewer
  1. // Returns the first element that is matching the specified group of selectors.
  2. var container = document.querySelector("#id");
  3. // Returns a list (NodeList) of elements matching the specified group of selectors.
  4. var matches = container.querySelectorAll(".class");
Programming Language: Javascript