HTML DOM Input Checkbox value Property

The Input Checkbox value property returns a string with the value attribute of input checkbox. User can also set it to a new string.


Following is the syntax −

  • Returning string value
  • Setting value attribute to a string value
inputCheckboxObject.value = ‘String’


Let us see an example of Input Checkbox value property −

 Live Demo

<!DOCTYPE html>
<title>Value Attribute of Checkbox</title>
<form id="Form">
Color-Red: <input value="Green" id="formCheckbox" type="checkbox" name="formCheckbox">
<button onclick="changeType()">Change value of input checkbox</button>
<div id="displayDiv"></div>
   var valueOfInput = document.getElementById("formCheckbox");
   var displayDiv = document.getElementById("displayDiv");
   displayDiv.textContent = 'Value: ' + valueOfInput.value;
   function changeType(){
      if(valueOfInput.value == 'Green' && valueOfInput.checked == true){
         valueOfInput.value = 'Red' displayDiv.textContent = 'value: ' + valueOfInput.value;
      } else {
         displayDiv.textContent = 'Check the checkbox to change value to red';


This will produce the following output −

Before clicking ‘Change value of input checkbox’ button −

After clicking ‘Change value of input checkbox’ button −

Checked ‘Color-Red’ checkbox & clicking ‘Change value of input checkbox’ button −