How to “Checked” a checkbox by using jQuery?

The problem is many beginner programmer have a question and i saw same question on various forum that how to checked a checkbox by using jQuery ? either single checkbox or multiple, so here i am going to solved the problem.

If you are using jQuery version 1.6 and onward then .prop() method is the best option for you, more about .prop method.

$(‘.yourCheckbox’).prop(‘checked’, true);
$(‘.yourCheckbox’).prop(‘checked’, false);

Yes of-course if you are using the version below 1.6 of jQuery then attr() method is available in jQuery, by using it you can checked the check box easily.

$(‘.yourCheckbox’).attr(‘checked’, true);
$(‘.yourCheckbox’).attr(‘checked’, false);

So you can see there are very simple methods are available in jQuery, which is also very easy to learn and understandable. Hope after read the post you got some knowledge.

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