xxxxxxxxxx
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Checkbox</title>
</head>
<body>
<label for="accept">
<input type="checkbox" id="accept" name="accept" value="yes"> Accept
</label>
<script>
const cb = document.querySelector('#accept');
if (cb){
console.log('checked');
}
else{
console.log('not checked');
}
</script>
</body>
</html>
xxxxxxxxxx
// Assuming the checkbox has an id attribute of 'myCheckbox'
var checkbox = document.getElementById('myCheckbox');
if (checkbox.checked) {
console.log('Checkbox is checked');
} else {
console.log('Checkbox is not checked');
}