Reputation: 47051
I'd love to change the order of HTML elements from:
<div id="d1">
<div id="dd1"></div>
<table id="t1"></table>
<div id="be_top"></div>
</div>
to:
<div id="d1">
<div id="dd1"></div>
<div id="be_top"></div>
<table id="t1"></table>
</div>
Does anyone have ideas about how to do this? Thanks!
Upvotes: 3
Views: 8172
Reputation: 569
Alternatively, You can use appendTo also in JQuery.
Ex :
var nav = $('#t1').clone(true);
$('#t1').remove();
nav.appendTo('#be_top');
Upvotes: 0
Reputation: 1074138
If you refer to the API documentation, you'll find the insertBefore
function:
$("#be_top").insertBefore("#t1");
Or of course, you could do it the other way around with insertAfter
:
$("#t1").insertAfter("#be_top");
An hour spent reading the API documentation beginning to end (and it really only takes that long) is hugely rewarding, saving you a lot of time over even just a brief period.
Upvotes: 9
Reputation: 16961
// select thing you want to move #be_top -> insert it before #t1
$("#be_top").insertBefore("#t1")
Upvotes: 2