javascript - Disable checkbox according to the selected option (jquery) -
i writing jquery code aim disable/enable group of checkboxes. far got: html:
<select id="units"> <option value="marketing" > marketing </option> <option value="finance" > finance </option> <option value="operations" > operations </option> </select> <input type="checkbox" class="enable" onclick="check();" value="1"> chbx1 <input type="checkbox" class="dissable" onclick="check();" value="2"> chbx2 <input type="checkbox" class="dissable" onclick="check();" value="3"> chbx3 <input type="checkbox" class="enable" onclick="check();" value="4"> chbx4 js
$("#units").on("change", function() { if ($(this).val() !== "finance") { $(".dissable").attr("disabled", "disabled"); } else { $(".dissable").removeattr("disabled"); } }); but doesn't work on page load. after change selected option checkboxes react. how improve in order catch selected value when page load , enabled/disabled checboxes apropriate class?
$(".dissable").attr("disabled", "disabled"); $("#units").on("change", function() { if ($(this).val() !== "finance") { $(".dissable").attr("disabled", "disabled"); } else { $(".dissable").removeattr("disabled"); } });
Comments
Post a Comment