JSFiddle - React, Tailwind, and code Playground

by konglie

HTML

<input type='checkbox' id='cb1'>CB 1<br/>
<input type='checkbox' id='cb2'>CB 2<br/>
<input type='checkbox' id='cb3'>CB 3

JavaScript

/**
konglie [at] kurungkurawal.com
for fun only
https://www.facebook.com/groups/mediatutorial.jquery.indonesia/permalink/1210955819012516/
*/

var cb1 = $('#cb1');
var cb2 = $('#cb2');
var cb3 = $('#cb3');

function matchMe(other, meIsChecked){
	if(!meIsChecked){
  	$(cb3).prop('checked', false);
    return;
  }
  
  if($(other).is(':checked')){
  	$(cb3).prop('checked', true);
  }
}

$(cb1).change(function(){
	matchMe(cb2, $(this).is(':checked'));
});

$(cb2).change(function(){
	matchMe(cb1, $(this).is(':checked'));
});