JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" class="output" value="" size="100"/>
<br>
   
    <input type="checkbox" class="mail" value="[email protected]">
    <br>
    <input type="checkbox" class="mail" value="[email protected]">
    <br>
    <input type="checkbox" class="mail" value="[email protected]">
    <br>
    <input type="checkbox" class="mail" value="[email protected]">
    <br>

JavaScript

$('input.mail').on('change', function () {
      if ($(this).is(':checked')) {
          $('.output').val($('.output').val() + $(this).val() + ", ");
      } else {
          currentVal = $('.output').val();
          currentVal = currentVal.replace($(this).val() + ", ", '');
          $('.output').val(currentVal);
      }
  });