Get Input Checkbox - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Checkbox

Introduction

The Input object represents an HTML <input> element with type="checkbox".

You can access an <input> element with type="checkbox" by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Checkbox: <input type="checkbox" id="myCheck">

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//from w w w.j  av  a2s  .  co m
    var x = document.getElementById("myCheck");
    x.checked = true;
    x.disabled = true;
    
}
</script>

</body>
</html>

Related Tutorials