if in html table have 5 row, 1 and 2 are safe, 3,4,5 must be saved as html structure to a variable. like this
var after2ndContent= '<tr><td>3</td></tr><tr><td>4</td></tr><tr><td>5</td></tr>'
if in html table have 5 row, 1 and 2 are safe, 3,4,5 must be saved as html structure to a variable. like this
var after2ndContent= '<tr><td>3</td></tr><tr><td>4</td></tr><tr><td>5</td></tr>'
As jQuery does not have an outerHTML function, it's a bit tricky:
$('<table>').append($('tr:gt(1)').clone()).remove().html();
That is:
gt()
is zero-indexed)<tr>
tags) and remove the elementIf you simply used $('tr:gr(1)').html()
, you'd probably just get the contents of the first <tr>
.
Since this is a continuation of your previous post, you can use this
var elemRemoved = $("#tbl1 tr:gt(1)").detach();
var removedContents = $("<div />").append(elemRem).remove().html();
alert ( removedContents );