Reputation: 414
Could someone please explain why the .append() method replaces table rows when sorting.
Why doesn't it add the sorted rows to the end of the unsorted rows?
Upvotes: 2
Views: 87
Reputation: 193271
$.fn.append
method of jquery is based on native Node.appendChild
method. This method inserts node to the end of the parent element it was called on, if new node is not yet in DOM tree. Or otherwise it moves node to new location. So it takes it from where it was previously and inserts to the end of the new parent.
Upvotes: 0
Reputation: 943661
It does append the row to the end, but since a row can't be in two places at once, it removes it from where ever it was before.
If the sort algorithm would put the first row last then it would:
Upvotes: 1