Languages
[Edit]
EN

jQuery - check if input checkbox is checked

14 points
Created by:
Aston-Freeman
787

In this article, we're going to have a look at how to check if the checkbox is checked with jQuery.

Quick solution:

 

A more detailed description of solutions is placed below.

1. prop method example

Edit

In this section prop method is used to get checked property value.

2. is method example

Edit

In this section is method is used with :checked selector to check the current state of the checkbox.

3. Subquery example

Edit

In this section checkbox element finding with a selector is described.

3.1. Selector example

Edit

3.2. find method example

Edit

4. Vanilla JavaScript mixed example

Edit

In jQuery, each function called with handled event uses as context DOM element on that event occurs. It makes it a simple way possible to check the checkbox state with Vanilla JS. In the below example checked property is used to get the current state of the checkbox.

5. attr method example

Edit

Note: this approach returns only checked attribute value - if state is changed by user interaction with UI it stays same - do not use it to check curent state (it is recomended to do not use it with onclick, onchange or oniput events too if developer does not now how it works).

A simple example of the problem is presented below. 

Alternative titles

  1. jQuery - how to check if input checkbox is checked?
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

jQuery

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join