jQuery 1.8.2 | Counter for both user-click and dynamically checked dynamically inserted checkboxes.
The following code works for user-click event on dynamically inserted class-based checkboxes:
- $('.aenable, .benable').live('change', function() {
- var chkbxchkd = $('.aenable:checkbox:checked, .benable:checkbox:checked').length;
- $('.counter').html('( ' + chkbxchkd + ' selected )');
- });
The problem is when I click on a button that toggles on and off the checked states of the class-based dynamically inserted checkboxes, the counter doesn't reflect the actual number of checked checkboxes. Basically, I need a live counter that constantly detects (and counts) user-clicked and dynamically checked or unchecked dynamically inserted class-based checkboxes. Any hint? - dan