How can I modify the following JS to where it will tell me whether the checkbox was checked or unchecked?
function toggleOption(x)
{
if (???)
alert("Checkbox with number " + x + " was checked");
else
alert("Checkbox with number " + x + " was UNchecked");
}
<input type="checkbox" onclick="toggleOption(1)">
To clarify I need to check if user clicking the checkbox made the checkbox checked, or unchecked. I don't need to check or uncheck the box using JavaScript (the user will be doing that part)