I am retrieving table row data like this from a HTML table.
var descriptions = [];
var testRows = $(\'#tbl\').find(\'tbody\').find(\'tr\');
$this = $(this);
If you use an older version of jQuery you can use .live() function. With newer version you should switch to .on(). But you can always make a function from what you wrote:
function example() {
var testRows = $('#tbl').find('tbody').find('tr');
$this = $(this);
testRows.each(function () {
var description = $this.find('[id^="Desc"]').text();
descriptions.push(description);
}
}
and run it every time you operate on your table:
function removeTr() {
$('tr').remove();
example();
}
I retrieved the data using fnGetNodes API method.
var descriptions = [];
var _testDesc;
var dt = $("tbl").dataTable();
var dtNodes = dt.fnGetNodes;
var dtNodeCount = dtNodes.length;
for (var i = 0; i < dtNodeCount; i++) {
var description = $(dtNodes[i].cells[2].innerHTML).val();
descriptions.push(description);
}
var descriptions = [];
var _testDesc;
var dt = $("tbl").dataTable();
var dtElementCollection = dt.DataTable.settings[0].aoData;
var dtECLength = dtElementCollection.length;
for (var i = 0; i < dtECLength; i++) {
var description = dtElementCollection[i]._aData[2];
_testDesc = $(description).val();
descriptions.push(_testDesc);
}