Input Checkbox value Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Checkbox


The value property sets or gets the value attribute of a checkbox.

Set the value property with the following Values

Value Description
text Sets the value associated with the input

Return Value

A String, representing the value of the value attribute of the checkbox

The following code shows how to return the value of the value attribute of a checkbox:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<form action="#">
  <input type="checkbox" id="myCheck" name="vehicle" value="Happy" checked>How are you today<br>
  <input type="submit" value="Submit">
</form>//from w w  w  .  j  a v a 2s. c o  m

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

<p id="demo"></p>

function myFunction() {
    var v = document.getElementById("myCheck").value;
    document.getElementById("demo").innerHTML = v;


Related Tutorials