0
Using pure Javascript, I performed the following query:
let elems = document.querySelectorAll("a.menu-item, span.menu-item");
After using the items of this nodeList
, i needed to use other elements that had previous tags and more a generic (like, for example, .nova-classe
). How do I perform a query to get the items with this class from within this nodeList without having to redo the entire query and without using JQuery
?
What I want is, more or less, the functioning of the pseudocode below:
var elem = documento.pesquisa("a.menu-item, span.menu-item")
// uso do nodeList "elem"
elem = elem.pesquisa(".nova-classe")
// uso do nodeList "elem"
elem = elem.pesquisa(".outros-elementos")
// uso do nodeList "elem"
You want to check whether the elements within the Nodelist have the new class or catch the children of the elements of its Nodelist?
– ayrton
check which elements of Nodelist have the new class
– Arthur Siqueira
but the children part is also interesting, there are already answers to this question?
– Arthur Siqueira
For the part of the children you could perform the
querySelectorAll
on each item ofNodeList
. This method can be used in any element, filtering only his children– ayrton