Question: I have check box and when "uncheck" checkbox is checked, 
all check box should be unchecked and "uncheck" checkbox should be checked. 

This is what I tried so far 

```
<input type="checkbox" name="" id="c1" class="checkbox nonCheck">  
<label for="c1"><span class="icon"></span>Uncheck</label>   

<input type="checkbox" name="" id="c2" class="checkbox">  
<label for="c2"><span class="icon"></span>value 1</label>   

<input type="checkbox" name="" id="c3" class="checkbox">  
<label for="c3"><span class="icon"></span>value 2</label>   

$(function(){
    $('.nonCheck').click(function(){
        $('input:checked').prop('checked',false).not('.nonCheck'); 
    }); 
})

```

But my code is not working. How do I change the code to fix it ? 
please help.

Answer: 
You need to check on every click on "any" checkbox for "Uncheck" is checked or not.

```js
let anyCheckbox = $(".checkbox");

anyCheckbox.on("click", function() {
 if($(".nonCheck").prop('checked'))
        anyCheckbox.not('.nonCheck').prop('checked', false);
})
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" name="" id="c1" class="checkbox nonCheck">
<label for="c1"><span class="icon"></span>Uncheck</label>

<input type="checkbox" name="" id="c2" class="checkbox">
<label for="c2"><span class="icon"></span>value 
 1</label>

<input type="checkbox" name="" id="c3" class="checkbox">
<label for="c3"><span class="icon"></span>value 2</label>
```

So whenever "Uncheck" is "checked" leave all other checkbox on `false`
Check this Code, I added a function to the **prop** attribute in jquery selector.This code is working as per your logic.

```
$(function(){
    $('.nonCheck').change(function(){
          $("input:checkbox").prop("checked", function( i, val ) {
            return !val;
          });
    }); 
})

```