ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How to uncheck checkbox using jQuery?

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

user-image
تم إضافة السؤال من قبل Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.
تاريخ النشر: 2013/04/10
Zaid Rabab'a
من قبل 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
من قبل Mohammed Sallam , Full-stack Software Engineer , Freelancing

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

Naina Singh
من قبل Naina Singh

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
من قبل 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
من قبل 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
من قبل 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
من قبل 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

حماده احمد ابوزيد
من قبل حماده احمد ابوزيد , 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
من قبل 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

المزيد من الأسئلة المماثلة