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
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: