Reputation: 3
Internet Explorer makes me crazy. Why won't this script work on IE?: http://jsfiddle.net/THMu3/
HTML:
<ul id="cat">
<li id="3">Text 3</li>
<li id="1">Text 1</li>
<li id="2">Text 2</li>
JS:
$("#cat li").sort(function (a, b) {
return parseInt(a.id) > parseInt(b.id);}).each(function(){
var elem = $(this);
elem.remove();
$(elem).appendTo("#cat");})
Upvotes: 0
Views: 167
Reputation: 8291
The solution is very simple actually. Change this
return parseInt(a.id) > parseInt(b.id)
to this
return parseInt(a.id) - parseInt(b.id)
Check here for more information: https://stackoverflow.com/a/949970/1845408
Upvotes: 1