Jquery - sort DIV's by innerHTML of children

后端 未结 4 734
醉话见心
醉话见心 2020-12-02 08:41

I\'ve got html that looks something like this:

Price:20
4条回答
  •  攒了一身酷
    2020-12-02 09:16

    Use my jquery plugin SortContent :

    $('#sortThis').sortContent({asc:true});
    

    You can use helper to sort according to the suitable conten that you want.

    $('#sortThis').sortContent({asc:true,helper:function(e){return $(e).find('.price').html()}})
    

    if you want to reverse order ,set false to asc option

    Another note, you can select directly children of div instead of parent: It is the same :

    $('#sortThis>div').sortContent({asc:true,helper:function(e){return $(e).find('.price').html()}})
    

    DEMO :

    http://jsfiddle.net/abdennour/ytmry/

提交回复
热议问题