Created
January 3, 2014 22:10
-
-
Save travismillerweb/8247630 to your computer and use it in GitHub Desktop.
JS - Remove Duplicate Elements (If More Than One)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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