I'm having an issue w/ a Content Editor Web Part. I would like to add an HTML table that gives users the ability to add and remove rows from a table. How should I add the following code to the CEW? Does it support this type of thing?
$('.AddNew').click(function(){
var row = $(this).closest('tr').clone();
row.find('input').val('');
$(this).closest('tr').after(row);
$('input[type="button"]', row).removeClass('AddNew')
.addClass('RemoveRow').val('Remove item');
});
$('table').on('click', '.RemoveRow', function(){
$(this).closest('tr').remove();
});
And the HTML:
<table>
<tr><td>Item Type</td><td>Item</td><td>Add/Remove Item</td></tr>
<tr><td><input type='text' value='Fruit >'></td>
<td><input type='text' value='Apple'></td>
<td><input type='button' class='AddNew' value='Add new item'></td></tr>
</table>
Thanks.