JSFiddle - React, Tailwind, and code Playground

by vasi_32

HTML

<div>
  <input type="checkbox" name="nom" value="1" /> Item un
  <input type="checkbox" name="nom" value="2" /> Item deux
  <input type="checkbox" name="nom" value="3" /> Item trois
</div>
<button id="activeBtn" disabled>Add</button>

JavaScript

function countChecked() {

    if ($('input[name="nom"]:checked').length > 0 && $("#activeBtn").is(':disabled')) {
        $("#activeBtn").removeAttr('disabled')
    } else if ($('input[name="nom"]:checked').length == 0) {
       $("#activeBtn").attr('disabled', true)
    }
};
$('input[name="nom"]').on("change", function(event) {
    countChecked();
});