remove duplicated based on value but keep the first content
by miloud_eloumri
HTML
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 4px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
var seen = {};
$('.check').each(function(){
var $this = $(this);
if(seen[$this.attr('value')]){
$this.closest("tr").next("tr").find("td.check").empty();
}else{
seen[$this.attr('value')] = true;
}
});
});
});
</script>
</head>
<body>
<table>
<tbody>
<tr>
<th>New ID</th>
<th>Year</th>
<th>Make</th>
<th>Model</th>
<th>Build</th>
<th>Pay</th>
<th>Date</th>
<th>From</th>
<th>To</th>
<th>Max</th>
<th>Used ID</th>
<th>Year</th>
<th>Make</th>
<th>Model</th>
<th>Name</th>
<th>Phone</th>
<th>Cell</th>
<th>Email</th>
<th>Address</th>
</tr>
<tr>
<td>id</td>
<td>year</td>
<td>make</td>
<td>model</td>
<td>build</td>
<td>pay</td>
<td>date</td>
<td>from</td>
<td>to</td>
<td>max</td>
<td class="check" value="1">1<br /><a href="#">View</a></td>
<td class="check" value="1">text1</td>
<td class="check" value="1">text1</td>
<td class="check" value="1">text1</td>
<td>name</td>
<td>phone</td>
<td>cell</td>
<td>email</td>
<td>address</td>
</tr>
<tr>
<td>id</td>
<td>year</td>
<td>make</td>
<td>model</td>
<td>build</td>
...