javascript - Delete rows from table recursively using JQ -
i want write recursive function delete rows table.
i have number of rows keep , after number want remove rows.
for example: have number 5 first 5 rows need stay , rest need go. (using row id)
code:
<table id="table"> <tr id="tr1"/> <tr id="tr2"/> <tr id="tr3"/> <tr id="tr4"/> <tr id="tr5"/> <tr id="tr6"/> <tr id="tr7"/> <tr id="tr8"/> </table>
i dont know how rows have, thats why think need recursive solution.
you can use several different jquery filter approaches:
var numrows=5; $('#table tr').slice(numrows).remove();
or
$('#table tr:gt(' + (numrows-1) + ')').remove();
references:
Comments
Post a Comment