javascript - sort list divs doesn't work -
i have sort multiple divs (which have "alldiv" class) according text in class "employe-name". multiple divs inside dive have "teamtablecontainer" id.
i got text sore according "asc" , when click on icon "desc" sort must done , vice versa×¥
the js code use is:
$('.formemployee .sort-arrow').click(function(){ if ($('.formemployee .sort-arrow').hasclass('down')) { $('.alldiv').sort(function(a,b) { $('.formemployee .sort-arrow').removeclass('down') $('.formemployee .sort-arrow').addclass('up') console.log($(b).find('.employe-name').text().touppercase()) return $(b).find('.employe-name').text().touppercase() >$(a).find('.employe-name').text().touppercase(); }).each(function( _, alldiv){ $(alldiv).appendto('#teamtablecontainer') }) } else { $('.alldiv').sort(function (a, b) { $('.formemployee .sort-arrow').addclass('down') $('.formemployee .sort-arrow').removeclass('up') return $(b).find('.last-name').text().touppercase() < $(a).find('.last-name').text().touppercase(); }).each(function (_, alldiv) { $(alldiv).appendto('#teamtablecontainer') }) } })
the sorting doesn't work should. why? , how can fix it?
Comments
Post a Comment