[Solved] Remove elements with same data-id


Not very inspired at the moment but with the amount of info you game us i made this example with jquery. It can be done also just with plain javaScript if needed

$('div').each(function() {
  dataId = $(this).data('id');
  otherDataId = $(this).siblings().data('id');
  if (otherDataId === dataId) {
  	$(this).hide()
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section>
    <div data-id="27">27</div>
    <div data-id="39">1</div>
    <div data-id="31">2</div>
    <div data-id="57">3</div>
    <div data-id="10">4</div>
    <div data-id="27">27</div>
    <div data-id="5">5</div>
    <div data-id="89">6</div>
</section>

4

solved Remove elements with same data-id