4

i can add checked property using following code

$('#specificCheckBox').prop('checked', true);

but how can remove this property using jquery or Javascript.

Swap L
  • 698
  • 3
  • 12
  • 27
  • possible duplicate of [check / uncheck checkbox using jquery?](http://stackoverflow.com/questions/17420534/check-uncheck-checkbox-using-jquery) – Somnath Kharat Jan 21 '14 at 13:02

3 Answers3

6

Don't remove it, but set it to false:

$('#specificCheckBox').prop('checked', false);
A. Wolff
  • 74,033
  • 9
  • 94
  • 155
  • 1
    on input element there no true or false only checked property is enough, that is confusion for me. – Swap L Jan 21 '14 at 12:58
  • @SwapL Here you want to set the property, not the attribute but ya it's quite confusing, see e.g: http://stackoverflow.com/questions/5874652/prop-vs-attr You could still set the attribute instead but using prop for this kind of 'property' is the preferred method – A. Wolff Jan 21 '14 at 13:01
  • @SomnathKharat that's true! But OP was asking to remove it which IMHO is quite different than usual similar questions and still doesn't explain why you have posted an answer too ;) – A. Wolff Jan 21 '14 at 13:15
  • issue is not for posting ans its for upvote and the qus is not for u.its for those who upvoted – Somnath Kharat Jan 21 '14 at 13:18
1

IN javascript:

document.getElementById("specificCheckBox").checked = false;

In Jquery:

$('#specificCheckBox').prop('checked', false);//version 1.6+
Somnath Kharat
  • 3,570
  • 2
  • 27
  • 51
0

here is the fiddle

$('#btnCheck').click(function(){
    $('#check').attr('checked', true);
});

$('#btnUncheck').click(function(){
    $('#check').attr('checked', false);
});
Indra Yadav
  • 600
  • 5
  • 22