Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JS - Remove Duplicate Elements (If More Than One)
/*
JS - Remove Duplicate Elements (If More Than One)
E.g. Removing duplicate breadcrumb items if there are intentially multiple copies of elements
Reference Link: http://stackoverflow.com/questions/2822962/jquery-remove-duplicate-elements
*/
var seen = {};
$('.crumb').each(function() {
var txt = $(this).text();
if (seen[txt])
$(this).remove();
else
seen[txt] = true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment