To get value of HTML checkbox from onclick/onchange events with JavaScript, we use the value property.
For instance, we write
<input type="checkbox" onclick="onClickHandler()" id="box" />
to add a checkbox.
We set the onclick attribute to call the onClickHandler function when we click on the checkbox.
Then we write
function onClickHandler() {
const chk = document.getElementById("box").value;
}
to define the onClickHandler function.
In it, we get the checkbox with getElementById.
Then we get the value of the checkbox from the value property.