Say I have an HTML structure like
<div id="a">
<div id="b">
<div id="c"></div>
</div>
</div>
To execute a query for children of "a" using querySelectorAll, I can do something like
//Get "b", but not "c"
document.querySelectorAll('#a > div')
My question is : is it possible to do this without an identifier, directly referring to node? I tried to do
var a_div = document.getElementById('a')
a_div.querySelectorAll('> div')
but I get an error indicating that the selected selector is invalid.
And in case someone wonders, my real use case would be something more complicated like "> .foo.bar.baz", so I would rather avoid manually bypassing the DOM. I am currently adding a temporary id to the root div, but this seems like an ugly hack ...