Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <button id='add' for-table='#example1'>Add Row</button>
- $("#add").click(function(e){
- var table = $(this).attr('for-table'); //get the target table selector
- var $tr = $(table + ">tbody>tr:last-child").clone(true, true); //clone the last row
- var nextID = parseInt($tr.find("input.tabledit-identifier").val()) + 1; //get the ID and add one.
- $tr.find("input.tabledit-identifier").val(nextID); //set the row identifier
- $tr.find("span.tabledit-identifier").text(nextID); //set the row identifier
- $(table + ">tbody").append($tr); //add the row to the table
- $tr.find(".tabledit-edit-button").click(); //pretend to click the edit button
- $tr.find("input, select").val(""); //wipe out the inputs.
- });
Add Comment
Please, Sign In to add comment