MaxwellLynn MaxwellLynn - 1 year ago 136
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?


Answer Source

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

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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download