0

Assuming this structure:

<div id="container">
    <div class="sortable">
        <div class="box">
        <h1>title1</h1>
        <h3 class="price">5</h3>
        </div>
    </div>

    <div class="sortable">
        <div class="box">
        <h1>title2</h1>
        <h3 class="price">1</h3>
        </div>
    </div>

    <div class="sortable">
        <div class="box">
        <h1>title3</h1>
        <h3 class="price">3</h3>
        </div>
    </div>
</div>

How can I sort the elements with the class .sortable to show in ascending/descending order based on the class .price inside of the divs? It should happen when clicking a button.

I know that with arrays I could use the .sort method, but as this is not an array, I don't really know how to approach this.

oneday
  • 1,599
  • 5
  • 18
  • 29
  • 1
    This is essentially a duplicate. The only real difference is that you'll need to get the `.price`'s value instead of the ` – Niet the Dark Absol May 26 '14 at 10:01
  • Thank you, I was researching before but it seems I didn't use the right words as I didn't find that thread, I'll take a look now! – oneday May 26 '14 at 10:09

0 Answers0