26 lines
587 B
Plaintext
26 lines
587 B
Plaintext
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Checkbox Example</title>
|
|
</head>
|
|
<body>
|
|
<label>
|
|
<input type="checkbox" id="myCheckbox"> Check me
|
|
</label>
|
|
|
|
<script>
|
|
const checkbox = document.getElementById('myCheckbox');
|
|
|
|
checkbox.addEventListener('change', function() {
|
|
if (checkbox.checked) {
|
|
console.log('Checkbox is checked - true');
|
|
// Do something when the checkbox is checked
|
|
} else {
|
|
console.log('Checkbox is not checked - false');
|
|
// Do something when the checkbox is not checked
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|