Created
January 19, 2015 01:51
-
-
Save davidpots/92c2357a82a15471fd91 to your computer and use it in GitHub Desktop.
Javascript notes
This file contains hidden or 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
// 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