For some reason, my form does not want to get the value of a checkbox... I am not sure if it is my coding or not, but when I try and alert()
the value, I get
You can use this code, it can return true
or false
:
$(document).ready(function(){
//add selector of your checkbox
var status=$('#IdSelector')[0].checked;
console.log(status);
});
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<label><input class="lifecheck" id="lifecheck" type="checkbox" checked >Lives</label>
<script type="application/javascript" >
lfckv = document.getElementsByClassName("lifecheck");
if (true === lfckv[0].checked) {
alert('the checkbox is checked');
}
</script>
</body>
</html>
so after you can add event in javascript to have dynamical event affected with the checkbox .
thanks
var elementCheckBox = document.getElementById("IdOfCheckBox");
elementCheckBox[0].checked //return true if checked and false if not checked
thanks