删除一列的重复单元格:html [英] Delete duplicate cells of a one column :html
本文介绍了删除一列的重复单元格:html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我按照这个做同样的事情。
< table id =testborder =1> ;
< tr>
< td> test1< / td>
< td> test2< / td>
< td> test3< / td>
< / tr>
< tr>
< td> test4< / td>
< td> test2< / td>
< td> test5< / td>
< / tr>
< tr>
< td> test6< / td>
< td> test2< / td>
< td> test9< / td>
< / tr>
< tr>
< td> test6< / td>
< td> test8< / td>
< td> test8< / td>
< / tr>
< / table>
说明:
$('#test td:first-child')
这有助于只选择表格的第一行
I am to do the same as per This
<table id="test" border="1">
<tr>
<td>test1</td>
<td>test2</td>
<td>test3</td>
</tr>
<tr>
<td>test4</td>
<td>test2</td>
<td>test5</td>
</tr>
<tr>
<td>test6</td>
<td>test2</td>
<td>test9</td>
</tr>
<tr>
<td>test6</td>
<td>test8</td>
<td>test8</td>
</tr>
</table>
LINK of Fiddle I am able to delete the duplicates from table all columns,but I want to delete duplicate cell values from only first column.
Orginal Output
Remove duplicates from total table getting output as
I want this
解决方案
Script
var seen = {};
$('#test td:first-child').each(function() {
// Encode column and content information.
var key = $(this).text();
if (seen[key]) {
$(this).text('');
}
else {
seen[key] = true;
}
});
Explanation:
$('#test td:first-child')
This helps to select only the first Row of the Table
这篇关于删除一列的重复单元格:html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文