0

I want to sort a list by price and quality (ascending and descending), by clicking on buttons.

As you can see in this sample I've used "data-x" to assign price and quality value to a product.

I can't do a function in Javascript that works, maybe there's a better way to assign price and quality.

Could you help me to create a function please? Thanks

<ul id="list1">
   <li data-price="25" data-quality="8">Product1</li>
   <li data-price="9" data-quality="9">Product2</li>
   <li data-price="17" data-quality="6">Product3</li>
</ul>
Marco P
  • 115
  • 1
  • 7
  • Check https://stackoverflow.com/a/38294718/5104748 – Mohammad Oct 02 '18 at 10:51
  • 1
    Possible duplicate of [jquery sort list based on data attribute value](https://stackoverflow.com/questions/21600802/jquery-sort-list-based-on-data-attribute-value) – Guillermo Cacheda Oct 02 '18 at 11:06
  • I've checked it but I still can't sort my items, I do something wrong. Could you please write here the function? Thanks – Marco P Oct 02 '18 at 19:55

0 Answers0