Skip to content

Instantly share code, notes, and snippets.

@davidpots
Created January 19, 2015 01:51
Show Gist options
  • Save davidpots/92c2357a82a15471fd91 to your computer and use it in GitHub Desktop.
Save davidpots/92c2357a82a15471fd91 to your computer and use it in GitHub Desktop.
Javascript notes
// On a page with many .item elements, where each element has many tags .item__tag
// This will create an array 'tagList' that contains all tags (without duplicates)
var tagList = [];
$.each( $('.item__tag'), function(i,obj) {
nextTag = obj.innerText;
if ($.inArray(nextTag,tagList) == -1) {
tagList.push( nextTag );
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment