PaoaRAed PaoaRAed - 11 months ago 57
jQuery Question

Check if Checkbox is checked is not working in JQuery

Here is my code it's always enter in else

ether that in console return true console

if ($('.DEL').prop('checked') == true)
{
// do a
}
else
{
//do b
}

Answer Source

This is a working code to get if the checkbox is checked or not:

if(document.getElementById('Your checkbox ID').checked) {
//a
} else {
//b
}

Or this way:

if($('#Your checkbox ID').is(':checked'))
   //a  
else
   //b

And according to your code:

if($('.DEL').is(':checked'))
   //a  
else
   //b

Or with the prop property:

if($('.DEL').prop('checked')) {
  //a
} 
else {
  //b
}