DataTabless Add rows
参考官网案例:https://datatables.net/examples/api/add_row.html
JS:
$(document).ready(
function
() {
var
t = $(
'#example'
).DataTable();
var
counter = 1;
$(
'#addRow'
).on(
'click'
,
function
() {
t.row.add( [
counter +
'.1'
,
counter +
'.2'
,
counter +
'.3'
,
counter +
'.4'
,
counter +
'.5'
] ).draw(
false
);
counter++;
} );
// Automatically add a first row of data
$(
'#addRow'
).click();
HTML:
<
table
id
=
"example"
class
=
"display"
cellspacing
=
"0"
width
=
"100%"
>
<
thead
>
<
tr
>
<
th
>Column 1</
th
>
<
th
>Column 2</
th
>
<
th
>Column 3</
th
>
<
th
>Column 4</
th
>
<
th
>Column 5</
th
>
</
tr
>
</
thead
>
<
tfoot
>
<
tr
>
<
th
>Column 1</
th
>
<
th
>Column 2</
th
>
<
th
>Column 3</
th
>
<
th
>Column 4</
th
>
<
th
>Column 5</
th
>
</
tr
>
</
tfoot
>
</
table
>
CSS:
www.52newblog.com,本博客专注于励志、人生、名人、故事、时事热点等富有正能量文章的分享。是一款简洁美观、自适应的博客系统。