JSFiddle - React, Tailwind, and code Playground
by adelura
HTML
<div>
foo
<ul>
<li>one</li>
<li>two</li>
<li>D<span>el</span>ura</li>
</ul>
<strong id="me">MEMEMEM</strong>
<br/>
<img alt="image"/>
</div>
CSS
.hidden {
visibility: collapse; !important;
}
JavaScript
function keep (el) {
let parent = el.parentNode;
let children = Array.from(parent.children);
children.forEach(child => {
if (child === el) {
return;
}
child.classList.add('hidden');
});
if (el === document.body) {
return;
}
keep(parent);
}
keep(me);