How do I check whether a checkbox is checked in jQuery?

How do I successfully query the checked property?

The checked property of a checkbox DOM element will give you the checked state of the element.

Given your existing code, you could therefore do this:

if(document.getElementById('isAgeSelected').checked) {
} else {

However, there’s a much prettier way to do this, using toggle:

$('#isAgeSelected').click(function() {
<script src=""></script>
<input type="checkbox" id="isAgeSelected"/>
<div id="txtAge" style="display:none">Age is something</div>

Leave a Comment