admin管理员组文章数量:1023220
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
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
本文标签: javascriptHow to add data inside datatable using jqueryStack Overflow
版权声明:本文标题:javascript - How to add data inside datatable using jquery? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745597328a2158249.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论