I need to get all the direct children of an element. As it is here:
-
One option is to use the direct child combinator, >, and the universal selector, *
, in order to select direct children elements of any type:
document.querySelectorAll('.element > *');
Alternatively, there is also a .children property that will return all the direct children elements:
document.querySelector('.element').children;
讨论(0)
- 热议问题