I am using checkboxes where the user can choose one or more options. I have managed to trigger an event if the checkbox has already been check (when retrieving info from the database). But I also want to trigger those same events when a checkbox is checked.
I have googled how to bind two events on jQuery but how can I do when it comes to an $('#item').is(':checked')
and $('#item').on('click', function(){})
.
Originally I am doing it like this within an if
only for .is(':checked')
:
if($('#item').is(':checked')){
//my stuff working fine so far
}
But I can't find out how to bind them inside the if
operator. I have tried the following, but I can't make it work.
if($('#item').is(':checked') || $('#item').on("click",function(){})){
//my stuff working fine so far
}
Any ideas?