I know the event name when we change something in a select is change
(html: onchange
), but I would like to know what is the event name when I select (click) a specific option.
Example :
<select>
<option>Option 1</option>
</select>
When I click on Option 1
, what event happen ? Only change
(on the select itself and all option) or something else ?
Thanks.
By default, in most browser happen change
event when you change select
and click
event for option
.
$('select').on('change', function(event) {
console.log(event.type); // event.type is to get event name
});
'change' on the SELECT and 'click' on the OPTION. Also, in Opera, 'input' might fire on the SELECT too if you add the listener with addEventListener() for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With