This is a useful jQuery Script that removes duplicates within an element such as a list. It simply cycles through an element and removes anything previously 'seen'.

Let's take a list of Cities as an example:-

  • London
  • Paris
  • Berlin
  • London (is removed as duplicate)
  • Dublin
  • Brussels

In this example we are cycling through a standard unordered list and removing duplicates, but you are recommended to give the list / element a class as otherwise you could be targeting other elements on the page where you want duplicates.