JSFiddle - React, Tailwind, and code Playground

HTML

<input id="test" type="checkbox"/>

JavaScript

console.log($('#test:checked').length);
$('#test').attr('checked', true);
console.log($('#test:checked').length);
$('#test').attr('checked', false);
console.log($('#test:checked').length);
$('#test').attr('checked', true);
console.log($('#test:checked').length);