jquery trigger change event on checkbox

That trigger is not a function error message indicates something else is at play. According to this SO question:

What happens when a jQuery selector wasn’t found?

no.good.at.coding says:

Do note however that you must ensure that selector is a jQuery object!
Otherwise, you could get an error indicating that “trigger is not a
function”.

It’s likely that you have forgotten jQuery?


As for your implementation, you should be fine the way you are using it. But trigger should be used to trigger event methods on elements that have already been attached via jQuery. Check out my demo:

Fiddle:
With click event: http://jsfiddle.net/fS4R5/1/
Without click event: http://jsfiddle.net/fS4R5/2/

HTML:

<label><input type="checkbox" id="chk"/>Label for chk</label>

JS:

function triggerChange(){
    $("#chk").trigger("change");
}

$("#chk").change(function() {
   alert("triggered!"); 
});

triggerChange();

Leave a Comment