I want to do is make a function that add data in my table and have a delete function in action column
using jquery.
My problem is I'm having trouble putting my input values in the table using jquery.
function Add(){
$("#myTable tbody").append(
"<tr>"+
"<td><input type='text'/></td>"+
"<td><input type='text'/></td>"+
"<td><input type='radio'/></td>"+
"<td><button class='btnDelete>Delete</button></td>"+
"</tr>");
$(".Save").bind("click", Save);
};
I want to do is make a function that add data in my table and have a delete function in action column
using jquery.
My problem is I'm having trouble putting my input values in the table using jquery.
function Add(){
$("#myTable tbody").append(
"<tr>"+
"<td><input type='text'/></td>"+
"<td><input type='text'/></td>"+
"<td><input type='radio'/></td>"+
"<td><button class='btnDelete>Delete</button></td>"+
"</tr>");
$(".Save").bind("click", Save);
};
Share
Improve this question
edited Jul 9, 2014 at 7:28
user3817023
asked Jul 8, 2014 at 22:24
user3817023user3817023
591 gold badge2 silver badges10 bronze badges
2 Answers
Reset to default 1If you are using datatable, then use datatable 'fnAddData' function for adding new row instead of jquery append function. Check the following code,
oTable = $('#myTable').dataTable();
function Add(){
var data = [
$('#input1').val(),
$('#input2').val(),
$('#input3').val(),
$('#input4').val()
];
oTable.fnAddData(data);
};
Here is legacy documentation for version 1.9.x
How to add row for version 1.9.x and below
Note: You better start using new version of data table 1.10.x