How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Check if a Checkbox Is Checked with jQuery
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > Web Development > How to Check if a Checkbox Is Checked with jQuery
Web Development

How to Check if a Checkbox Is Checked with jQuery

how7o
By how7o
Last updated: May 22, 2026
4 Min Read
jQuery check if a checkbox is checked
SHARE

To check if a checkbox is checked with jQuery, the cleanest one-liner is $('#myCheckbox').prop('checked') — returns true or false based on the live DOM state. Alternative forms (.is(':checked'), :checked selector + .length) all work and have their place. Don’t use .attr('checked') — it reads the original HTML attribute, not the live state.

Contents
  • TL;DR
  • Pick the method that reads cleanly
  • Don’t use .attr('checked')
  • React to state changes
  • Frequently asked questions
  • Related guides
  • References

Last verified: 2026-05-17 with jQuery 3.7+. Originally published 2023-01-05, rewritten and updated 2026-05-17.

TL;DR

// Single checkbox — get the live boolean state
if ($('#agree').prop('checked')) {
  // ...
}

// Reads English-style
if ($('#agree').is(':checked')) {
  // ...
}

// "Are any of these checked?"
if ($('input[type="checkbox"]:checked').length) {
  // at least one is checked
}

// Vanilla JS
if (document.getElementById('agree').checked) {
  // ...
}

Pick the method that reads cleanly

All three jQuery forms work; choose based on what you’re expressing:

  • .prop('checked') — best for boolean math (assigning to a variable, passing to a function). Returns the literal boolean.
  • .is(':checked') — best inside an if for readability. Reads “if the element is checked…”
  • $('selector:checked').length — best for “is any of these checked?” without writing a loop.
jQuery check if checkbox is checked — .prop, .is(':checked'), :checked selector, vanilla JS

Don’t use .attr('checked')

// MISLEADING — returns the original HTML attribute, not the live state
$('#agree').attr('checked');     // "checked" or undefined, no matter what the user did

The HTML checked attribute reflects only the default state from the markup. After the user clicks, the live state lives on the DOM property — which is what .prop() reads. This trap has been the subject of “jQuery checkbox not working” Stack Overflow questions for over a decade.

React to state changes

$('#agree').on('change', function () {
  console.log('Checked:', this.checked);
});

this inside the handler is the raw DOM checkbox, so this.checked gives you the live boolean without wrapping in jQuery.

Frequently asked questions

Which method is the cleanest — :checked, .prop(), or .is()?

For a single checkbox: $('#agree').prop('checked') returns a boolean directly. For a selector that might match many checkboxes (“is any of these checked?”): $('input:checked').length > 0. For a one-off readability win inside a conditional: $('#agree').is(':checked') reads almost like English. All three are equivalent; pick the one that reads cleanest in context.

Why does $('#cb').attr('checked') sometimes give wrong results?

Because .attr('checked') reads the original HTML attribute (the default state from the markup), not the live state after the user clicks. .prop('checked') reads the live DOM property. For ‘is it checked right now?’ always use .prop() — this was the jQuery 1.6+ recommendation and still holds.

Can I do this without jQuery?

Yes: document.getElementById('agree').checked for a single element, or document.querySelectorAll('input:checked').length for a count. Native JS has been comfortable for this since forever — jQuery’s only advantage is the terse selector syntax.

How do I run code when the checkbox state changes?

Wire up the change event: $('#agree').on('change', function () { console.log(this.checked); });. The this inside the handler is the raw DOM element, so this.checked is the boolean state at the moment of the event.

Related guides

  • How to Add the Required Attribute to Input Fields with jQuery
  • How to Check if an Element Is Hidden in jQuery
  • How to Change a Checkbox Background Color with CSS

References

jQuery .prop(): api.jquery.com/prop. :checked selector: api.jquery.com/checked-selector.

TAGGED:JavaScriptjQuery

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Check Bootstrap modal open or closed with jQuery How to Check if a Bootstrap Modal Is Open or Closed with jQuery
Next Article Check if an element is hidden or visible with jQuery How to Check if an Element Is Hidden or Visible with jQuery
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Set vi as the default editor in Ubuntu — a terminal opening the vim editor
How to Set vi (Vim) as the Default Editor in Ubuntu
June 8, 2026
rsync says ALL DONE but files are missing — a terminal showing ALL DONE next to an empty folder
rsync Says “ALL DONE” but Files Are Missing: How to Verify
June 8, 2026
Migrate a website to a new server with rsync — files copying from an old server to a new one over SSH
How to Migrate a Website to a New Server With rsync
June 8, 2026
Bun runtime — faster JS toolkit replacing npm in Laravel projects
How to Install Bun Runtime on Ubuntu (And Use It in a Laravel Project)
May 24, 2026
Tailscale mesh — peer-to-peer connections between devices, coordination server
How to Install Tailscale on Ubuntu (Zero-Config Mesh VPN for Self-Hosters)
May 24, 2026

You Might Also Like

Rename menu items on the WooCommerce My Account page
Web Development

How to Rename Menu Items on the WooCommerce My Account Page

4 Min Read
WordPress disable revision and autosave — wp-config constants and wp_print_scripts dequeue
Web Development

How to Disable Revisions and Autosave in WordPress

8 Min Read
Check Bootstrap modal open or closed with jQuery
Web Development

How to Check if a Bootstrap Modal Is Open or Closed with jQuery

4 Min Read
Laravel migration column types cheat sheet
Web Development

Laravel Migration Column Types — Cheat Sheet

5 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?