Categories: jQuery

How to check checkbox with jQuery?

Share

The correct way to check checkbox on the DOM elements can be done using jQuery .prop or .attr method.

By using JavaScript’s “checked” property, we can solve the problem directly, instead of manipulating the DOM into doing what we want it to do.

To check checkbox see the below script:

After jQuery version 1.6 you can use:

$('.chkID').prop('checked', true);
$('.chkID').prop('checked', false);

And jQuery version 1.5x and below you can use:

$('.chkID').attr('checked', true);
$('.chkID').attr('checked', false);

Read: jQuery Checkbox checked property

This plugin will alter the checked property of any DOM elements selected by jQuery, and successfully check or uncheck checkboxes under all circumstances.

Recent Posts

Warm Comfort: Choosing the Best Hot Water Bottle for Cozy Nights

Introduction: As the chill of winter settles in or a bout of cold weather strikes,…

5 mins ago

One Location, Different Perspectives: The Allure of Dubai Marina Apartments

Nestled along the glittering waterfront of the City of Gold, Dubai Marina beckons to discerning…

25 mins ago

Role Of Gojek Clone In Growth Campaigns For Your Business

When was the last time you heard that a clone app like Gojek could efficiently…

6 hours ago

How to Optimize Your E-Commerce Pages and Improve UX?

The e-commerce market is growing and evolving at a rapid pace. More and more people…

17 hours ago

Overview of Reputation, Services, and Features of IplWin

IplWin stands as a reliable and enthralling platform for Indian punters, offering a captivating blend…

3 days ago

Blogging Brilliance: Driving Traffic and Engagement with Quality Content

Introduction In today's online age, consumers are constantly bombarded with information. They crave valuable content…

3 days ago