javascript - DataTable pagination only can count checkboxes of first page -


i have table, pagination. created script count check boxes checked on table. works on first page, when select second page, doesn't count when select.

here script:

<script>     $(document).ready(function(){     var data = {         '300x250': 0,         '160x600': 0,         '728x90': 0,         '300x600': 0,         '300x300': 0,         '120x600': 0,         '100x72': 0,         '970x250': 0,         '750x200': 0,         '120x60': 0,         '200x600': 0,     }      function registerevents() {         $(".checkbox").on("change", function() {             var value = $(this).is(":checked") ? 1 : -1;             var key = $(this).attr('value').split('_')[0];             console.log(key, value);             data[key] += value;             printdata();         });     }      function printdata() {         $("#result").html(json.stringify(data, " ", 4));         $("#result300x250").html(json.stringify(data['300x250'], " ", 4));      }      registerevents();     }); </script> 

hope explained well, thanks

are checkboxes in dom on page load?

perhaps selector should along lines of:

$("#tableid").on("change", ".checkbox", function(){     /*your function here*/ }); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -