If there is something like this:
<div id="one">
...other elements inside...
</div>
<div id="two">
...other elements inside...
</div>
I know you can do:
$("#two").before($("#one"));
But what about this situation when you have something like this:
<div id="one">
...other elements inside...
</div>
<div id="two">
...other elements inside...
</div>
<div id="three">
...other elements inside...
</div>
<div id="four">
...other elements inside...
</div>
<div id="five">
...other elements inside...
</div>
<div id="six">
...other elements inside...
</div>
<div id="seven">
...other elements inside...
</div>
<div id="eight">
...other elements inside...
</div>
and you want to swap #eight
and #four
how would you do that in Jquery? Each div contains a lot of code and this code is dynamically changed so only the #one
, #two
, etc. of the main divs are stable and callable.