How to sort DOM elements while selecting in jQuery?

后端 未结 4 1900
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 14:29

I have the following DIVs on my page:

Div 3
Div 2
4条回答
  •  眼角桃花
    2020-11-28 14:56

    $("div[id^=pi_div]").sort(function (a, b) {
        return a.id.replace('pi_div', '') > b.id.replace('pi_div', '');
    }).foo();
    

    http://jsfiddle.net/KrX7t/

提交回复
热议问题