What is the best way to catch a < select > change event? I have a form that has different input elements but I want to trigger an event only in the case of a < select > change. I don’t want to use the ID since there are a lot of selects on the form.
Many thanks in advance!
If you want only some selects in the page to have the change event, you can add a class to them, like so:
And then you can catch the change event from any of these by doing something like:
If you want to select all of them, you can just change your selector to be
Inside the function, you can refer to the select elements by using
$(this), so a code like this:Will alert the selected option of any
<select>tags with a class ofchoose_meon change.