-1
if(!$('input:value').is(:checked)){

//do something

}

How do i do this, i can´t find an example? I want to know if a checkbox with a specific value has been checked.

as997
  • 47
  • 5
  • You can use the [attribute value selector](https://api.jquery.com/attribute-equals-selector/) – empiric Jan 25 '18 at 13:09
  • Do you want to check every time it's checked status is changed, or only at runtime? In one way or another, using this expression will perform the check for you: `$('input[value="X"]').not(:checked)`. However, if you want to check its value whenever its state is being updated, you will need to bind an event listener to it. – Terry Jan 25 '18 at 13:11
  • Okay, if i have a variable called x, can i do this? $('input[value=x]').not(:checked) – as997 Jan 25 '18 at 13:45

2 Answers2

0

loop through checkboxex and then check as below

var c=$(".commonclassname");
for(var i=0;i<c.length;i++)
{
   if(c[i].value=="your value")
   {
     //matched...
   }
}
Uttam Suthar
  • 106
  • 6
0

Here's how to detect if a checkbox with a particular value gets unchecked

$("input[type=checkbox]").click(function() {
    if ($(this).val() == "test2" && !$(this).is(":checked")) {
        alert("Unchecked Test2");
    }
});

Fiddle: https://jsfiddle.net/vwm28b7u/1/