Reputation: 27685
How can I add rows <tr>
in to a table a any level(Top/Bottom/In between) using Javascript/jQuery
?
Upvotes: 0
Views: 116
Reputation: 14382
$(html).insertBefore($('table tr').eq(index));
Will insert some html
before the tr
with index specified.
Upvotes: 2
Reputation: 3948
you have nothing to do, because you just have to find the parent element and then append it.
well, it is more complicated, but I think is possible. One way is following:
find the parent element from the rows and read all rows into an extra variable. Fortunatly the result will be an array of object. Then create a new row element and use the method unshift()
to put this at the begin of the array. Clean table's body and then add each element to body again.
Upvotes: 0