vendredi 17 février 2017

jquery: detect change in any element which falls under a class

Ok so I have many checkboxes on a page. I need to detect when any one of these checkboxes are clicked / changed so I can run a function. Let's say that function simply prints the ID of the checkbox to the console. Here's what I have so far: http://ift.tt/2kHCgiE

I'm trying to give each checkbox input the same class myCheckboxes so I can just detect a change in that class, identify exactly which input I clicked using the this keywork and then run the function (not sure if this works or not). I'm also curious if there's a better solution without using the this keyword. I'm very new to Javascript so sorry if this question doesn't make sense.




Aucun commentaire:

Enregistrer un commentaire