mercredi 27 septembre 2017

Jquery multiple checkboxes with same id issue

i have this problem with multiple checkboxes with the samen id (#group) if one of these checkboxes is checked another checkbox with the id (#user) should be checked as well. The problem is that with $this it works like a charm but then again you have also the checkboxes without the #group id. I made this fiddle to demonstrate the problem.

http://ift.tt/2xFTOW3

here is the simple Jquery

$('input').on('change', function() {
  var totalSeen = $("input#group:checked").length;
  if ($('#group').prop("checked")) {
    $('#user').prop('checked', true);
    return;
  } else if (totalSeen == 0) {
    $('#user').prop('checked', false);
    return;
  }
});




Aucun commentaire:

Enregistrer un commentaire