jquery remove duplicate

I have table which is bound dynamically:
    <table id="test">
    <tr>
    <td>test1<td>
    </tr>
    <tr>
    <td>test2<td>
    </tr>
    <tr>
    <td>test1<td>
    </tr>
    <tr>
    <td>test2<td>
    </tr>
    </table>
I want to remove duplicate table rows, producing a result like this.
    <table id="test">
    <tr>
    <td>test1<td>
    </tr>
    <tr>
    <td>test2<td>
    </tr>
    </table>
sol
var seen = {};
$('table tr').each(function() {
    var txt = $(this).text();
    if (seen[txt])
        $(this).remove();
    else
        seen[txt] = true;
});
demo

credit: http://stackoverflow.com/questions/8234107/remove-duplicate-trs-through-jquery

โพสต์ยอดนิยมจากบล็อกนี้

J2EE คืออะไร

วิธีแก้ : แก้ไขตารางแล้ว save ไม่ได้ ต้องสร้างใหม่ - Saving changes is not permitted in SQL Server Management Studio

การออกแบบ RESTful API - วิธีปฏิบัติที่ดี