Reputation: 13080
how remove html table rows after 2nd row? if in table have 5 row, 1 and 2 are safe, 3,4,5 must be remove
Upvotes: 3
Views: 3911
Reputation: 187030
Use detach() instead of remove()
var myremovedElems = $("#table tr:gt(1)").detach();
The .detach() method is the same as .remove(), except that .detach() keeps all jQuery data associated with the removed elements. This method is useful when removed elements are to be reinserted into the DOM at a later time.
Upvotes: 5