Brain ache.
I have a timer that dynamically adds row to a table. I want an event to fire when the user clicks on one of the dynamically added rows.
I'm tagging each for with a class of "PortletTableUseButton" and using the .on("click") but it doesn't work.
$('.PortletTableUseButton').on("click", function () {
alert($(this));
});
setInterval(function () { addRow(); }, 2000);
var counter = 2042;
function addRow() {
counter++;
var myRow = "<tr class='PortletTableUseButton'><td>BLOCK-" + counter + "</td><td>Location A</td><td >Use</td></tr>";
$("#Portlet #content tr:last").after(myRow);
}
<div id="Portlet" style="position:absolute; top:500px;left:500px; height:200px;">
<div id="content" style="height:80%;">
<table id="PortletTable">
<tr>
<td>File Name</td>
<td>Location</td>
<td>Action</td>
</tr>
</table>
</div>
</div>