Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to uncheck checkbox using jQuery?

i have a problem with checkboxes , even if i change -- check = "unchecked"

user-image
Question added by Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.
Date Posted: 2013/04/10
Zaid Rabab'a
by Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.

i try this and it working :D $("#id").prop('checked', true); i think it same as Mariusz Walczyk said :D

Try: $('#checkbox_id').attr('checked', false);

Mohammed Sallam
by Mohammed Sallam , Full-stack Software Engineer , Freelancing

I usually use this: $('#id').removeAttr('checked');

Use prop() not attr() for this as attr() will not work in newer versions of jquery. Do jquery uncheck checkbox

$('#myCheckbox').prop('checked', false);

 

 

Muhammad Ahsan Mirza
by Muhammad Ahsan Mirza , Software Development Engineer , Remit Anywhere Solutions

To uncheck a check box, use $("#id").attr('checked',false); or simply remove the attribute like $("#id").removeAttr('checked');

Hazem Salama
by Hazem Salama , Senior Member of Technical Staff , Verizon Communications

I'd have to second people who suggested you use $('#id').prop('checked', false) vs using attr() Prior to jQuery 1.6, jquery did not make a distinction between what's a property and what is an attribute of the element, and everything was handled via attr(), which made it a beast.
As of 1.6, they made the decision to handle properties via prop, which is meant to be more cross-browser.
For detailed explanation see this http://blog.jquery.com/2011/05/10/jquery-1-6-1-rc-1-released/

Zaher Hazeem
by Zaher Hazeem , Senior Software Engineer , N2V - Startappz

try this, it's fast way to swap the current value, from check to unchecked and vice versa: Check Me

this will change the value:

$("#theChk").prop("checked",true)

this will get you the value:

$("#theChk").prop("checked") or $("#theChk").attr("checked")

Abdullah Akram
by Abdullah Akram , Full Stack Developer , Ertekaz Technology

I think answer to your solution is here: just copy paste to your editor,n locate the jquery pakage.
n just try to check uncheck with a single button...cheers!!!!! jQuery check / uncheck a check box example jQuery check / uncheck a check box example Check Me

حماده احمد ابوزيد
by حماده احمد ابوزيد , Senior Web Developer , Pixel for information technology

<inputtype="checkbox"id="myCheckbox"checked="checked"/><!-- Checked --><inputtype="checkbox"id="myCheckbox"/><!-- Unchecked --> $('#myCheckbox').attr('checked',true);// Checks it $('#myCheckbox').attr('checked',false);// Unchecks it

However, you cannot trust the .attr() method to get the value of the checkbox (if you need to). You will have to rely in the .prop() method.

So, for jQuery 1.6+

Use the new .prop() function as:

$('#myCheckbox').prop('checked', true); // Checks it $('#myCheckbox').prop('checked', false); // Unchecks it

Muhammad Awais Mughal
by Muhammad Awais Mughal , Senior PHP Developer , Bookme.pk

<inputtype="checkbox"id="myCheckbox"checked="checked"/><!-- Checked --><inputtype="checkbox"id="myCheckbox"/><!-- Unchecked -->$('#myCheckbox').prop('checked',true);// Checks it $('#myCheckbox').prop('checked',false);// Unchecks it

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.