Jquery Table row UP DOWN DEL INS - Clear Cloned row cell contents?
How to clear the cell contents of a cloned row?
I am mixed up with this, children, each, etc... Help?
<table id="myTable" class="order-list">
<tbody>
<tr><td>
<a href="#" class="up">Up</a>
<a href="#" class="down">Down</a>
<a href="#" class="DelRow">Del</a>
<a href="#" class="AddRow">Ins</a>
</td><td>
<input type="text" name="name" />
</td><td>
<input type="text" name="price" />
</td></tr>
</tbody>
</table>
// Add row
$(".AddRow").on('click', function(){
$curRow = $(this).parent().parent();
$newRow = $curRow.clone(true);
// Empty td values in input:text of current tr
$curRow.children().each(function() {
alert("M- " + $('td', this).text());
$('td', this).empty();
});
$curRow.before($newRow);
});
http://jsfiddle.net/humm64/j83XB/
No comments:
Post a Comment