Search for nested DOM elements
In jQuery, you can search a child element using the find() function. The equivalents in JavaScript are querySelector()
or querySelectorAll()
functions on an element.
Refer to the following code snippet to learn how to search a child element through jQuery and vanilla JavaScript:
// Searching a child element inside an element using jQuery.
let blogsSection = $(".blogs-section");
blogsSection.find(".blog-post");
// Searching a child element inside an element using vanilla JavaScript.
let blogsSection = document.querySelector(".blogs-section");
blogsSection.querySelector(".blog-post");