Instead of using the filter
function you could use an object to collect all the feed titles with their jQuery elements. The object will behave just like a HashMap
in Java since objects can't contain duplicate keys - so duplicate feed titles are eliminated automatically.
var unique = { };
// Reverse elements to keep first occurence of feed title (and not the last one)
$($(".feedburnerFeedBlock li").get().reverse()).each(function(){
// Use feed title as key and jQuery element as value
unique[$(this).find("a").text()] = $(this);
}).hide();
// Show all unique elements
for (title in unique) {
unique[title].show();
}
JSFiddle: http://jsfiddle.net/Aletheios/9GKBH/1/
Besides, your code doesn't work because of several reasons. Amongst others jQuery's .html()
function only returns the HTML string of the first element in the set (see documentation).