Answer the question
In order to leave comments, you need to log in
querySelectorAll function and first child selector?
Let's say I have some element node. It is necessary, without resorting to cycles, childNodes and matchesSelector , to find first-level descendants that match some selector, for example 'div.classname1.classname2[title$="bla"]'. One solution is the following:
node.querySelectorAll('#node1 > div.classname1.classname2[title$="bla"]'); //при условии, что node.id==="node1"
Obviously, this only helps if the selector node (in this case "#node1") is known and unique. var id = node.dataset.randomId = Math.random();
node.querySelectorAll('[data-random-id="'+id+'"] > div.classname1.classname2[title$="bla"]');
node.querySelectorAll('> div.classname1.classname2[title$="bla"]');
Answer the question
In order to leave comments, you need to log in
http://ejohn.org/blog/thoughts-on-queryselectorall/
This is a spec bug.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question