Currently I am having an issue exactly like in the article jQuery DataTables - Why click event handler does not work.
My code is something like below:
$('input[id^="remove_button"]').each(function(){
$(this).click(function(){
alert('hello');
});
});
<table id="example<?php print $counter ?>" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>cn</th>
</tr>
</thead>
<tfoot>
<tr>
<th>cn</th>
</tr>
</tfoot>
<tbody>
<?php
for ($i = 0; $i < $users["count"]; $i++) {
print '<td><input type=submit id=remove_button'.$i.' value="remove" /></td>';
}
?>
</tbody>
</table>
I need to achieve as below:
$('table[id^="example"]').on('click', '.btn-details', function(){
showModalDialog(this);
}
In my case tables are generating dynamically and so will have dynamic table ids. 'Remove Button' exists in each each row of every table.
I tried in many ways, but I am unable to make code to look like as above. Could anyone please help me on the issue above?