Skip to content

Instantly share code, notes, and snippets.

@travismillerweb
Created January 3, 2014 22:10
Show Gist options
  • Save travismillerweb/8247630 to your computer and use it in GitHub Desktop.
Save travismillerweb/8247630 to your computer and use it in GitHub Desktop.
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