This code works when adding a dynamic table with data coming from an ajax request but can not remove the dynamic table. I code below shows whenever I click on a tree node, it should load its mysql table data into a HTML table.
$("#treeNodes").on("select_node.jstree", function(event, data)
{
var node = data.rslt.obj;
var nodeID = node.attr("id");
event.stopImmediatePropagation;
if(/leaf/.test(nodeID))
{
$(".tableData > *").remove(); // remove all table data (tr rows) before adding the new data and not working or firing off.
addTableData(); // This function get the data from a mysql table and loads it into an HTML table.
}
});
<table>
<tbody class='tableData'></tbody>
</table>
Would someone kindly show me how this code can recognize the newly added dynamic table data so it can be removed?