0

I have a checked Checkbox to be unchecked based on some condition.

Tried writing the below code:

$('.chkCouponNumber8').prop('checked', false);

But I am unable to achieve .. Kindly help!

msapkal
  • 8,268
  • 2
  • 31
  • 48

3 Answers3

0

please try:

if($(".chkCouponNumber8").prop('checked') == true){
    //do something
}
else
{
   //do something different
}

you can also try:

if (!$(".chkCouponNumber8").is(":checked")) {
    // do something if the checkbox is NOT checked
}
else
{
   //do something different
}
0

Can you try this:

$('#test').prop('checked', false); // if you are using id as selector



 $('.Classname').prop('checked', false); // if you are using class as selector

make sure your jquery is 1.6+ version

hope this helps..

Sai Avinash
  • 4,683
  • 17
  • 58
  • 96
0

Please try this. HTML

<input type="checkbox" checked="checked" class="chkCouponNumber8">

Javascript/jQuery

if($('.chkCouponNumber8').attr('checked')){
   // do something
}else
{
 // do something
}

or

var x = document.getElementById("chkCouponNumber8").checked;
if(x== true)
{
// do something
}else
{
// do something
}
Tarun Gupta
  • 6,305
  • 2
  • 42
  • 39