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!
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!
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
}
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..
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
}