Wednesday, January 30, 2013

jQuery to remove duplicate items from array

Find jQuery code to remove duplicate items from an array using $.unique().
$(document).ready(function () {
var arr = [10, 19, 22, 36, 50, 74, 10, 22];
$('#dvallElements').html(arr.join("<br />"));
arr = $.unique(arr);
$('#dvUniqueItems').html(arr.sort().join("<br />"));
});
See result below


See Complete Code
Feel free to contact me for any help related to jQuery, I will gladly help you.

No comments:

Post a Comment