Sort table row from data attribute
in Using jQuery
•
7 years ago
Hi,
I have the following code and despite all my attempts it doesn't sort. I've console.log before and after and it's the same. When I debug the comparison it returns the right value. I'm wondering what I'm doing wrong
- var Elements = $('#tablecontent tr');
- $(Elements).sort(function (a, b) {
var contentA = $(a).data(SelectedSORT == 'ROOM' ? 'appartment' : 'fullname');
var contentB = $(b).data(SelectedSORT == 'ROOM' ? 'appartment' : 'fullname'); - return (contentA < contentB ? 1 : 0);
}); - $('#tablecontent').empty
$('#tablecontent').append(Elements);
1