MaxwellLynn MaxwellLynn - 11 months ago 75
jQuery Question

Click event not firing on checkbox

Am I going crazy?

I can't get a click event to fire on a checkbox.

This is my JS:

$(document).ready(function() {
$('.checkbox').on('click', function () {

This is my php/html:

<ul class="category-filters">
<input class="checkbox" value="Customer Service" type="checkbox">Customer Service
<input class="checkbox" value="HR" type="checkbox">HR</li>

It is worth pointing out that if I change the function/method to hide then it works...

but it does not trigger a click event. I've used on and click to try this..

Is it because the class selector I'm using returns an array?



One way to do it is to use the change event.

$('input').on('change', function() {