JSFiddle - React, Tailwind, and code Playground
by shimmy
HTML
<div id="parent">
<div id="0">
<div id="dummy"></div>
<div id="1">
<div id="2">
<div id="3">
<div id="child">
<span>some text</span>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
div
{
padding: 20px;
}
#parent
{
background-color: green;
}
#child
{
background-color: red;
}
JavaScript
var child = $('#child');
var parent = undefined;
do
{
child.unwrap();
var parent = child.parent();
alert(parent.attr('id'));
}
while (parent.attr('id') != 'parent')
child.siblings().remove();