Skip to main content
Better ckeck
Source Link

I am using this and this is working absolutely fine:

if($("#checkkBoxId").attr("checked"))
{
   ? alert("Checked");
}
else
{
   : alert("Unchecked");
}

Note: If the checkbox is checked it will return true otherwise undefined, so better check for the "TRUE" value.

I am using this and this is working absolutely fine:

if($("#checkkBoxId").attr("checked"))
{
    alert("Checked");
}
else
{
    alert("Unchecked");
}

Note: If the checkbox is checked it will return true otherwise undefined, so better check for the "TRUE" value.

I am using this and this is working absolutely fine:

$("#checkkBoxId").attr("checked") ? alert("Checked") : alert("Unchecked");

Note: If the checkbox is checked it will return true otherwise undefined, so better check for the "TRUE" value.

remove unnecessary true comparison
Source Link
Bonifacio2
  • 3.7k
  • 6
  • 37
  • 56

I am using this and this is working absolutely fine:

if($("#checkkBoxId").attr("checked")==true)
{
    alert("Checked");
}
else
{
    alert("Unchecked");
}

Note: If the checkbox is checked it will return true otherwise undefined, so better check for the "TRUE" value.

I am using this and this is working absolutely fine:

if($("#checkkBoxId").attr("checked")==true)
{
    alert("Checked");
}
else
{
    alert("Unchecked");
}

Note: If the checkbox is checked it will return true otherwise undefined, so better check for the "TRUE" value.

I am using this and this is working absolutely fine:

if($("#checkkBoxId").attr("checked"))
{
    alert("Checked");
}
else
{
    alert("Unchecked");
}

Note: If the checkbox is checked it will return true otherwise undefined, so better check for the "TRUE" value.

Post Made Community Wiki by Udit Bhardwaj
Source Link
Pradeep
  • 417
  • 1
  • 5
  • 2

I am using this and this is working absolutely fine:

if($("#checkkBoxId").attr("checked")==true)
{
    alert("Checked");
}
else
{
    alert("Unchecked");
}

Note: If the checkbox is checked it will return true otherwise undefined, so better check for the "TRUE" value.