Odyssey
Odyssey

Reputation: 263

Making divs go backwards in order

Here's some example code

<div id="one">One</div><div id="two">Two</div><div id="three">Three</div>

And let's say the CSS is

div {float:left;}

Is there anyway to make the divs appear as Three, Two, One, besides something like float:right? JavaScript and jQuery not excluded.

Upvotes: 4

Views: 287

Answers (1)

Nate B
Nate B

Reputation: 6344

That's actually the exact example used on this JQuery documentation page for $.makeArray():

var elems = document.getElementsByTagName("div");
var arr = jQuery.makeArray(elems);
arr.reverse();
$(arr).appendTo(document.body);

Upvotes: 5

Related Questions