CheckBox get selected / checked as true or false in Javascript and JQuery

Swapnil
No Comments

Checkbox has an attribute checked which can have two values "checked" or "unchecked" we have to just check it with "checked" value to checked attribute of checkbox.

$('#mycheckbox').is(':checked') ? true : false;

 

In plain javascript we can do it simply by

var checkbox = document.getElementById("mycheckbox").checked;

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Search