Delete records

by alano

HTML

<table id="records">
    <tr data-val="1">
        <td>Record 1</td>
        <td><span class="delete"></span></td>
    </tr>
    <tr data-val="2">
        <td>Record 2</td>
        <td><span class="delete"></span></td>
    </tr>
</table>

CSS

#records span.delete {
    margin-left: 10px;
    text-decoration: underline;
    cursor: pointer;
    color: blue;
}
#records span.delete:before {
    content: "Delete";
}

JavaScript

$(document).ready(function(){
    $("#records").on("click", "span.delete", function(){
        if (confirm("Are you sure you wish to delete record " + $(this).closest("tr").data("val") + "?")){
            //put your delete code here, for example...
            $(this).closest("tr").remove();
        }
    });
});