我对 jquery 和 fooTable 很陌生。
我想要做的是结合FooTable提供的添加和删除jquery函数,这样当我添加一行时,它会自动删除该表中的最后一行。
非常感谢这里的一些帮助。谢谢!
//This piece of code deletes a row
$('table').footable().on('click', '.row-delete', function(e) {
e.preventDefault();
//get the footable object
var footable = $('table').data('footable');
//get the row we are wanting to delete
var row = $(this).parents('tr:first');
//delete the row
footable.removeRow(row);
});
//This piece of code adds a row
$('.add-row').click(function(e) {
e.preventDefault();
//get the footable object
var footable = $('table').data('footable');
//build up the row we are wanting to add
var newRow = 'Some content here'
//add it
footable.appendRow(newRow);
});