333.How do you get the status of a checkbox? the id attribute is missing in input tag.

1
closed
nikikalwar
nikikalwar
Posted 3 months ago

333.How do you get the status of a checkbox? the id attribute is missing in input tag. #162

<input type="checkbox" id="checkboxname" value="Agree" /> Agree the
conditions<br />

console.log(document.getElementById('checkboxname').checked);

It's giving error for the original question so changed the name attribute to id attribute or we can add id attribute only and leave the name attribute as it is.

sudheerj
sudheerj
Created 1 month ago

The input is already having id attribute. Thanks. Closing it now