<head> <script src= "http://code.jquery.com/jquery-1.7.min.js" type="text/javascript"></script> </head> <body> <table width="779" border="5" id="test"> <tr class="tablerow"> <td>ee</td> <td>11</td> <td>test</td> <td>3</td> <td>15974079 </tr> <tr> <td>ww1</td> <td>hi</td> <td>test2</td> <td>d</td> <td>15859779 </tr> <tr class="tablerow"> <td>ww2</td> <td>hi</td> <td>test2</td> <td>t </td> <td>15974386</td> </tr> <tr> <td>ww2</td> <td>hi</td> <td>test4</td> <td>e</td> <td>15974386</td> </tr> <tr> <td>ww4</td> <td>hi</td> <td>test5</td> <td>d</td> <td>15974652</td> </tr> <tr> <td>sssd</td> <td>fgdg</td> <td>test6</td> <td>dzz</td> <td>15974652</td> </tr> <tr> <td>sssd</td> <td>d</td> <td>test7</td> <td>d</td> <td>15974652</td> </tr> </table> <script> var arr = $("#test tr"); $.each(arr, function(i, item) { var currindex = $("#test tr").eq(i); var matchtext = currindex.children("td").eq(2).text(); $(this).nextall().each(function(i, initem) { if(matchtext===$(this).children("td").eq(2).text()) { $(this).remove(); } }); }); </script> </body>maybe duplicate question tried many links , couldn't answer.
i need remove duplicate row base on third column, not first 1 use eq instead first, not work probably,actually in small table works when number or rows , columns big doesn't work example: doesn't display forth row not duplicate when choose eq(4)or eq(2) in row "ww4" checked 1 work first column
i tried 1 1 check column in row not base on 1 columns need check value of third row
<head> <script src= "http://code.jquery.com/jquery-1.7.min.js" type="text/javascript"></script> </head> <body> <table width="779" border="5" id="test"> <tr class="tablerow"> <td>ee <td>11 <td>test <td> <td>15974079 </tr> <tr> <td>ww1 <td>hi <td>test2 <td> <td>15859779 </tr> <tr class="tablerow"> <td>ww2 <td>hi <td>test2 <td> <td>15974386 </tr> <tr> <td>ww2 s<td>hi <td>test4 <td> <td>15974386 </tr> <tr> <td>ww4 <td>hi <td>test5 <td> <td>15974652 </tr> <tr> <td>sssd <td>fgdg <td>test6 <td>dzz <td>15974652 </tr> <tr> <td>sssd <td> <td>test7 <td> <td>15974652</tr> </table> <script> var arr = $("#test tr"); $.each(arr, function(i, item) { var currindex = $("#test tr").eq(i); var matchtext = currindex.children("td").eq(2).text(); $(this).nextall().each(function(i, initem) { if(matchtext===$(this).children("td").eq(2).text()) { $(this).remove(); } }); }); </script> </body>
try this
var seen = {}; $('table tr').each(function() { var txt = $(this).children("td:eq(2)").text(); if (seen[txt]) $(this).remove(); else seen[txt] = true; });
Comments
Post a Comment