Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8666633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:46:41+00:00 2026-06-12T17:46:41+00:00

How do I reorder dom elements based on the css position left? I have

  • 0

How do I reorder dom elements based on the css position left?

I have 3 elements, with left values of 10, 20, and 30 percent, and position: absolute.

In the DOM, they’re in the order 20, 10, 30 but I’d like to order them ascending according to the left attribute (10, 20, 30).

All three elements are inside a div with id parent

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:46:42+00:00Added an answer on June 12, 2026 at 5:46 pm

    You’ll need to loop through the child elements as an array so that they can be sorted, and then you need to reattach the children in the right order. This can be done in pure JavaScript without jQuery:

    var parent = document.getElemntById(parent),
        children = [];
    
    // loop through the child nodes, add them to your array
    // and remove them from the parent
    for (var i = parent.childNodes.length-1; i >= 0; i--) {
        children.push(parent.childNodes[i]);
        parent.removeChild(parent.childNodes[i]);
    }
    // sort them based on the left property
    children.sort(function(a,b){
        return window.getComputedStyle(a)['left'] - window.getComputedStyle(b)['left'];
    });
    // add them back to the parent in order
    for (var i in children) {
        parent.appendChild(children[i]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My main goal is to try to reorder a CSS style block based on
I have a html table that I reorder based on a CSV list of
I have a vector contains a,b,c,d,e vec[2] is c, but will it automatically reorder
I have been attempting to reorder a table in a database based on category
How can I use something like jQuery & PHP to reorder elements within an
I'd like to reorder li elements through an array with jQuery My list code
I'd like to reorder the array of annotations shown on a map in order
How do I reorder the column headers in code AS IF I have clicked
What does reorder() function do in Joomla? I have a statement for a function
A compiler cannot eliminate or reorder reads/writes to a volatile -qualified variables. But what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.