Sorting elements with jQuery using data attributes

后端 未结 2 1244
再見小時候
再見小時候 2021-01-25 04:10

Just to let you know, I\'m a rookie. I try to programm a certain function for the menu-navigation on my website. (http://thomasmedicus.at/)

I want visitors on my website

2条回答
  •  北海茫月
    2021-01-25 04:45

    Refer to this site for sorting algorithms http://www.sorting-algorithms.com/. You should go by scalability to overcome future problems with sorting.Array.sort() is helpful. Check this fiddle http://jsfiddle.net/BF8LV/2/

        function sortAscending(data_A, data_B)
    {
        return (data_A - data_B);
    }
    var array =[ 9, 10, 21, 46, 19, 11]
    array.sort(sortAscending) 
    alert(array);
    

提交回复
热议问题