JSFiddle - React, Tailwind, and code Playground

HTML

<input class="v" type="checkbox" value="one, " data-for="#text1" />
<input id="text1" /><br />
<input class="v" type="checkbox" value="two, " data-for="#text2" />
<input id="text2" />

JavaScript

$('body').on('change', '.v', function() {
  var inputSelector = $(this).data('for');
	$(inputSelector).val($(this).is(':checked') ? $(this).val() : ', ');
});