SO - 18225499

by Arun P Johny

HTML

<table>
    <tr>
        <td id="example">
            Something is inside here.
            <button id="paymentBtn">pay</button>
        </td>
    </tr>
</table>
<button id="add">Add</button>
<button id="remove">Remove</button>

JavaScript

$('#add').click(function(){
    $("#paymentBtn").before("inserted new one");
})
$('#remove').click(function(){
    $($("#paymentBtn").get(0).previousSibling).remove();
})