I have the following HTML
<select>
<option value="">filter</option>
<option data-behavior="toggle-visibility" data-scope="a" value="a">a</option>
<option data-behavior="toggle-visibility" data-scope="b" value="b">b</option>
</select>
and I need to fire up a Javascript callback when any of the options is selected.
I have the following piece of Javascript:
$(function() {
$(document).on("EVENT", "[data-behavior~=toggle-visibility]", function() {
...
});
});
Is there an event I can use to achieve my goal?
PS - I understand I could move data-behavior="toggle-visibility"
to the select
tag and then listen for change
and get the currently selected value. However, since that piece of Javascript is already used with other elements, I need to keep the data-behavior
attribute on the option
s.
It should work here https://jsfiddle.net/xpvt214o/535895/