How to Check if Checkbox is Checked or not in jQuery

This tutorial show you how to check, Is checkbox either checked or not in jQuery?. To check checkbox is checked or not is very simple task, after searching on the internet i am going to discuss the easiest and authentic solution of it. Here i describe three solutions, its depend on you which you follow or your which jQuery version you are using.

<input id=”checkbox1″  type=”checkbox” name=”first” value=”1″ >
<input id=”checkbox2″ type=”checkbox” name=”second” value=”2″ checked=”checked”>
<input id=”checkbox3″ type=”checkbox” name=”third” value=”3″>

1. Check by using .prop() jQuery method.

$(‘#checkbox’).prop(‘checked’)  // Boolean true if checked

2. Check by using .is() jQuery method.

$(‘#checkbox’).is(‘:checked’)  // Boolean true if checked

3. Check by using .length or .size() jQuery methods

// Selecting the checkbox & filtering by :checked selector
$(‘#checkbox:checked’).length  // Integer >0
$(‘#checkbox:checked’).size()  // .size() can also be used instead of .length

Which is the recommended method for check the checkbox is checked or Not in JQuery?

The answer is .prop method is recommended for check the checkbox in jQuery. .prop method available 1.6 and latest version of jQuery. A .prop method is used to sets and return properties or values of the selected elements. In the previous version of jQuery .attr() method was used instead.

About Moazzam Qureshi

I am SEO expert and web developer since 2011. My hobby is to write & provides quality content about blogging, SEO , Social Media , Earn Online and Affiliate Marketing.

Leave a Reply

0 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
0 Comment authors
Recent comment authors
newest oldest most voted