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: 
Check this Code, I think this will help you

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

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<input type="checkbox" name="" id="c1" class="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>   
```
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;
          });
    }); 
})

```