The issue is that IDs
is array of strings not numbers, so inArray
never works as you expect, because you are trying to find a number in array of strings. Try to change map method to this:
var IDs = $("#list li[id]").map(function () {
return +this.id;
}).get();