Sorting Divs in jQuery by Custom Sort Order

后端 未结 6 637
名媛妹妹
名媛妹妹 2021-01-31 11:35

I\'m trying to re-sort the child elements of the tag input by comparing their category attribute to the category order in the Javascript variable category_sor

6条回答
  •  死守一世寂寞
    2021-01-31 12:23

    Just note,

    Since there is jQuery 1.3.2 sorting is simple without any plugin like:

    $('#input div').sort(CustomSort).appendTo('#input');
    function CustomSort( a ,b ){
         //your custom sort function returning -1 or 1
         //where a , b are $('#input div') elements
    }
    

    This will sort all div that are childs of element with id="input" .

提交回复
热议问题