Remove duplicate elements from list by value with jQuery

jQuery is very useful and easy to learn and it’s very, very powerful. If you look at the code below you’ll see that with a few lines of code we are able to remove duplicate content from the list.

Here is my HTML

<ul >
  <li value="1" name="test" id="test1">test 1<li>
  <li value="1" name="test" id="test3">test 3<li>
  <li value="1" name="test" id="test3">test 3<li>
  <li value="3" name="test" id="test4">test 4<li>
  <li value="4" name="test" id="another1">another 1<li>
  <li value="5" name="test" id="another1">another 2<li>
   <li value="5" name="test" id="another1">another 2<li>
  <li value="4" name="test" id="another3">another 3<li>
</ul>

Here is my CSS

.list {
  
  list-style:none;
}

Here is jQuery

$(document).ready(function(){
  var found = {};
  $('li').each(function(){
    var $this = $(this);
    if(found[$this.attr('value')]){
      $this.remove();
    }else{
      found[$this.attr('value')] = true;
    }
  });
});

You can also read this

Random name picker with Javascript

My wife and I will become parents. I believe most...

?

start
stop

Awesome reponsive table

Recently I had one custom CRM project where I had...

.responsive-table tbody td[data-title]:before {
    content: none;
  }