JSFiddle - React, Tailwind, and code Playground
HTML
<div id="bar">
<div id="h2">01</div>
<div id="h2">02</div>
<div id="h2">03</div>
<div class="h1">1
<div id="a1">8</div>
</div>
<div id="h2">2</div>
</div>
JavaScript
function reverseChild($parent, index)
{
// Retrieve the child item with the supplied (ZERO BASED!) index
var childItem = $parent.children('div:nth-child('+ index +')');
// Place it in front of it's immedeate previous sibling.
childItem.parent().next().after(childItem);
};
$(document).ready(function()
{
//alert('he');
reverseChild($('#bar .h1'), 1);
});