Answer the question
In order to leave comments, you need to log in
How to sort by values inside list items?
There is a list like:
<ul>
<li>Книг <span>15</span></li>
<li>Журналов <span>5</span></li>
<li>Альбомов <span>25</span></li>
</ul>
Answer the question
In order to leave comments, you need to log in
$('li').sort((a, b) => $('span', b).text() - $('span', a).text()).appendTo('ul');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question