JSFiddle - React, Tailwind, and code Playground
HTML
<input id="chk" type="checkbox" value="Click Me!" checked="checked" />
<input type="text" id="txt" />
<input type="button" value="test" />
JavaScript
$(function() {
//check the enabled state on load
if ($("#chk").is(":checked")) {
$("#txt").attr("disabled", "disabled");
}
//toggle the enabled state when the checkbox is clicked
$("#chk").click(function() {
var el = $("#txt");
if (el) {
el.removeAttr("disabled");
if (this.checked) {
el.attr("disabled", "disabled");
}
}
});
});