JSFiddle - React, Tailwind, and code Playground

by maxx0r

HTML

<form>
  <p>
     Deze tag is bij geen van de artikelen actief. Als je hem aanvinkt dan wordt hij bij alles toegevoegd, zoals het nu ook is.
      <br />
    <input type="checkbox" id="cb1">
    <label for="cb1">Internationaal nieuws</label>
  </p>
      <br /> <br />
  <p>
   Een deel van je selectie heeft deze tag. Als je hem uitvinkt wordt hij overal weggehaald. Vink je hem aan wordt hij bij alle artikelen toegevoegd.
      <br />
    <input type="checkbox" id="cb2"   onclick="ts(this)">
    <label for="cb2">Nationaal nieuws</label>
  </p>
</form>

JavaScript

/* fork from code sent to me by "Casual Trash" */
$(document).ready(function() {
 var cb = $("#cb2")
 cb.prop("readOnly", true);
 cb.prop("indeterminate", true);   
});
function ts(cb) {
    cb = $(cb);
    if (cb.prop("readonly")) {
        console.info("readonly");
        cb.prop("checked", false);
         cb.prop("readOnly", false);
    } else if (!cb.prop("checked"))  {
        console.log("not checked");
           
         cb.prop("readOnly", true);
        cb.prop("indeterminate", true);        
    }
}