I am dynamically creating a list of input boxes in JQuery and have an event to notify me when they are checked.
$("#myDiv").on("change", "input[type='checkbox']" , function(){
if(this.checked){
alert("HERE");
//...
}else{
alert("THERE");
//...
}
});
When the page loads and all the checkboxes show – I can have this enter by checking/unchecking. The problem is that I want a few of these to be checked initially depending on the results of my backend logic. So I want to enter this function after the initial load.
I looked at .trigger() and .click() however, neither seem to do the trick.
Is there another avenue I could take to enter this callback?
In this case you can create a named function instead of using an anonymous one and call it whenever you need.