Disable/Enable checkboxes and comboboxes

by A B

HTML

Checkbox:&nbsp;<input type="checkbox" value="1" id="myCheckBox" />
<br />
Combo:&nbsp;<select id="myCombo">
  <option>Milk</option>
  <option>Coffee</option>
  <option>Tea</option>
</select>
<br /><br />
<button id="tryDisable">Disable</button><button id="tryEnable">Enable</button>

JavaScript

$("#tryDisable").click(function() {
    $("#myCheckBox").attr("disabled", true);
    $("#myCombo").attr("disabled", true);
});

$("#tryEnable").click(function() {
    $("#myCheckBox").attr("disabled", false);
    $("#myCombo").attr("disabled", false);
});