How To Order List Items By Simple Hierarchy In Page
I got a list of link (error message) pointing to a control into a page. The order of links is not the same as the control there pointing to. I want to reorder my links. sample :
Solution 1:
You can sort the errors based on the index of the element it belongs to
$('#errorList a').sort(function(a,b) {
var data1 = $(a).data('idcontrol'),
data2 = $(b).data('idcontrol'),
index1 = $('#' + data1).index(),
index2 = $('#' + data2).index();
return index1 - index2;
}).appendTo('#errorList');
Post a Comment for "How To Order List Items By Simple Hierarchy In Page"