You bind the controls that exist at the time the page loads.
Instead:
$(':checkbox').click(...)
Do you want to use:
$(document).on('click', ':checkbox', ...)
This will allow you to handle the click event of flags created after the page loads.
source
share