get-children-without-parent-selector
v0.1.10
Published
A function that takes an element and returns all descendants of that element, but does not return those whose parent element has the supplied selector.
Downloads
3
Readme
Installation
Type yarn add get-children-without-parent-selector
at the command line to add this to your project.
Usage
<div class="foo" id="alpha">
<div class="foo_bar" id="beta">
<div class="foo" id="gamma">
<div class="foo_bar" id="delta"></div>
</div>
<div class="qux">
<div class="foo_bar" id="epsilon"></div>
</div>
</div>
<div>
<div class="foo_bar" id="zeta"></div>
</div>
</div>
import getChildrenWithoutParentSelector from 'get-children-without-parent-selector';
const foo1 = document.getElementById('alpha');
const foo2 = document.getElementById('gamma');
// returns #beta, #epsilon and #zeta only
getChildrenWithoutParentSelector(foo1, '.foo_bar', '.foo');
// returns #delta only
getChildrenWithoutParentSelector(foo2, '.foo_bar', '.foo');