jQuery: Sort div's according to content of different sub divs

后端 未结 1 1531
迷失自我
迷失自我 2020-12-09 06:47

I\'m trying to create a somewhat complex sorting feature which neither uses divs nor lists. Unfortunately two hours of googling didn\'t help me.

Here is the basic s

1条回答
  •  轮回少年
    2020-12-09 07:19

    Try these comparison functions instead:

    function sortAscending(a, b) {
        return $(a).find("h3").text() > $(b).find("h3").text() ? 1 : -1;
    };
    function sortDescending(a, b) {
        return $(a).find("h3").text() < $(b).find("h3").text() ? 1 : -1;
    };
    

    0 讨论(0)
提交回复
热议问题