0
                <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 is duplicate question but i tried many links and couldn't get my answer.

I need to remove duplicate row base on third column, not first one use eq instead first, but its not work probably,actually in very small table works but when the number or rows and columns get big its doesn't work for example: doesn't display forth row even not duplicate when i choose eq(4)or eq(2) in row "ww4" i checked this one but its only work with first column

i tried this one too but that one is check all column in row not only base on one columns i need check only 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>
7
  • 3
    Invalid Markup: <td> is not closed. Commented Jan 29, 2016 at 6:59
  • what do you mean, what line then ? Commented Jan 29, 2016 at 7:02
  • it means for every <td> you have, you must end with a </td> Commented Jan 29, 2016 at 7:05
  • @KuroshSol : what do you mean "what line" ,,, you tell us on which line you closed the td tag Commented Jan 29, 2016 at 7:05
  • Possible duplicate of Remove duplicate <tr>'s through jquery Commented Jan 29, 2016 at 7:11

1 Answer 1

2

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;
});

http://jsfiddle.net/VbUxd/440/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.