Issue with checkbox listener in multifield

Issue with checkbox listener in multifield

I have a multifield component with a 1 checkbox in each item. I am adding a listener so that if one check box is checked all others should be unchecked automatically. I am writing the listener with jquery. When I check the next item in multifield, the functionality works fine, however, it doesn't work when I check a previous checkbox in the multifield item.

whats around with this code:


Check = 

function(e) {
   $("input[name='./isActive']").each(function () {
    if($(this).attr('id') !==  e.id && $(this).attr('checked') && e.getValue() !== false) {
     if (confirm('Do you want to replace Alert message?')) {
      $(this).removeAttr('checked');
      return;
     } else {
      e.setValue(false);
      return;
     }
    }
   });
 }