JSFiddle - React, Tailwind, and code Playground
HTML
<p>
surrounding text
</p>
<p id="iShouldBeInsideTheBox">
This should be inside the box
</p>
<p>
surrounding text
</p>
<p id="box">
Some content in the box
</p>
<button id='toggle'>Toggle</button>
CSS
#box{
border: 1px solid #000;
}
JavaScript
function toggle(){
if(jQuery('#box #iShouldBeInsideTheBox').length > 0)
jQuery('#iShouldBeInsideTheBox').insertAfter('body p:eq(0)');
else
jQuery('#box').append(jQuery('#iShouldBeInsideTheBox'));
}
jQuery('#toggle').click(toggle);