Question: I need to know when any checkbox on the page is checked:

e.g.

```
<input type="checkbox">

```

I tried this in Jquery

```
$('input type=["checkbox"]').change(function(){
alert('changed');
});

```

But it didn't work, any ideas?

Answer: 
Use the `change()` event, and the `is()` test:

```
$('input:checkbox').change(
    function(){
        if ($(this).is(':checked')) {
            alert('checked');
        }
    });

```

I've updated the above, to the following, because of my silly reliance on jQuery (in the `if`) when the DOM properties would be equally appropriate, and also cheaper to use. Also the selector has been changed, in order to allow it to be passed, in those browsers that support it, to the DOM's `document.querySelectorAll()` method:

```
$('input[type=checkbox]').change(
    function(){
        if (this.checked) {
            alert('checked');
        }
    });

```

For the sake of completion, the same thing is also easily possible in plain JavaScript:

```
var checkboxes = document.querySelectorAll('input[type=checkbox]'),
    checkboxArray = Array.from( checkboxes );

function confirmCheck() {
  if (this.checked) {
    alert('checked');
  }
}

checkboxArray.forEach(function(checkbox) {
  checkbox.addEventListener('change', confirmCheck);
});

```

---

References:

* JavaScript:
	+ [`Array.from()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from).
	+ [`Array.prototype.forEach()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).
	+ [`document.querySelectorAll()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll).
	+ [`EventTarget.addEventListener()`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener).
* jQuery:
	+ [`:checked`](http://api.jquery.com/checked-selector/).
	+ [`change()`](http://api.jquery.com/change/).
	+ [`is()`](http://api.jquery.com/is/).
```
$("input[type='checkbox']").click(function(){
    alert("checked"); 
});

```

Just a normal `.click` will do.