what\'s the best way to remove the grapes duplicate from this? there are tons of ways of removing duplicates from simple arrays, but this would be an array with html element
:has expects an element selector while :contains takes a string
:has
:contains
see http://api.jquery.com/contains-selector/
so this should do the trick:
$('.fruit').each(function () { $('.fruit:contains("' + $(this).text() + '"):gt(0)').remove(); });
fiddle: http://jsfiddle.net/kam7E/