I would like to use some JS to perform a function if a checkbox is checked. However, my input field checkbox keeps returning false when it’s checked and I can’t understand why.
Here’s the HTML:
<input id="option_service_desk" type="checkbox"/>
Here’s the JS:
if (document.getElementById('option_service_desk').checked)
{
console.log('service 247 checked');
} else {
console.log("service 247 not checked");
}
I’ve tried checking in the console and indeed, it’s returning as false, even though it is checked on the screen.