Javascript DOM HTML Input Checkbox disable and enable

Introduction

Disable and enable a checkbox:

View in separate window

<!DOCTYPE html>
<html>
<body>

Checkbox: <input type="checkbox" id="myCheck">

<button onclick="disable()">Disable checkbox</button>
<button onclick="enable()">enable checkbox</button>

<script>
function disable() {/*from ww  w  . j av  a 2  s.  c o  m*/
  document.getElementById("myCheck").disabled = true;
}

function enable() {
  document.getElementById("myCheck").disabled = false;
}
</script>

</body>
</html>



PreviousNext

Related