TheWebs
TheWebs

Reputation: 12913

Using Jquery to change the order of a div on page load

I am just curious if it is possible to take Jquery and do something where:

<div class="test">
<div class="test2">

is then flipped to:

<div class="test2">
<div class="test">

Keep in mind that both divs are displayed, neither is hidden. This doesnt do some fancy animation or anything like that, instead all it does on page load is swap the order of the divs and continues on like nothing ever happened.

Ideas?

Upvotes: 0

Views: 534

Answers (1)

asafreedman
asafreedman

Reputation: 572

This might be a little convoluted but it swaps the nodes, placing it directly before .test

Fiddle: http://jsfiddle.net/cC2hH/

$('.test').before($('.test2').remove());

Upvotes: 1

Related Questions