Pagination click event not working on page numbers

2019-08-11 12:01发布

问题:

I am using the jquery datatables . I want to perform some functions on click of pagination numbers of the table . The rows of the table are getting generated dynamically. The issue is that the onclick event is not getting fired when clicking on numbers but it is getting fired on the previous and next links.

I have used the following to bind the click function :

 $(document).on('click',"div.pagination li",function(evt){
 evt.preventDefault();
 alert('clicked!');
 // do some coding
  });

Kindly help me in identifying what is the mistake here. Kindly suggest if there is an alternative method.

Thanks!

回答1:

If the pagination links are created through JQuery then .click may not work instead use .bind