EaBangalore EaBangalore - 2 months ago 13
jQuery Question

click on td is not working for all in dataTable

i'm using dataTable plugin.


  • i want to edit or delete the particular row, so onclick on
    <td>
    iam planning to capture id.



but the problem when i go to next tab onclick is not working. it is working only for the present item.

here is a fiddle : http://jsfiddle.net/UvjnT/1191/

Please click on the item and see the alert. Then go to next tab, click but will not work? Why?

Answer

Try this code. You can see difference between .click() and .on("click") here

$(document).ready(function() {
   $('#example').dataTable({"sPaginationType": "full_numbers"});
   $('#example').on("click","td",function(){
     alert($(this).text());
   });
});