JSFiddle - React, Tailwind, and code Playground

by alex_ball

HTML

<table class="myTable">
    <tr>
        <td id="1">1</td>
        <td id="2">2</td>
        <td id="3">3</td>
        <td id="1">1</td>
    </tr>
    <tr>
        <td id="4">4</td>
        <td id="5">5</td>
        <td id="6">6</td>
        <td id="2">2</td>
    </tr>
    <tr>
        <td id="7">7</td>
        <td id="7">7</td>
        <td id="7">7</td>
        <td id="8">8</td>
    </tr>
</table>    

<button id="removeID">Remove by ID</button>
<button id="removeVal">Remove by Val</button>

JavaScript

function removeD(w){
    var seen = {};
    if(w == 'val'){
        $('table tr td').each(function() {
            var txt = $(this).text();
            if (seen[txt])
                $(this).remove();
            else
                seen[txt] = true;
        });
    }else{
        $('table tr td').each(function() {
            var id = $(this).attr('id');
            if (seen[id])
                $(this).remove();
            else
                seen[id] = true;
        });
    }
}

$('#removeID').click(function(){
    removeD('id');
});



$('#removeVal').click(function(){
    removeD('val');
});