I bound an event on the change event of my select elements with this:
$('select').on('change', '', function (e) {
});
How can I access the element which got selected when the change event occurs?
I bound an event on the change event of my select elements with this:
$('select').on('change', '', function (e) {
});
How can I access the element which got selected when the change event occurs?
I find this shorter and cleaner. Besides, you can iterate through selected items if there are more than one;
Delegated Alternative
In case anyone is using the delegated approach for their listener, use
e.target
(it will refer to the select element).JSFiddle Demo
You can use the jQuery find method
The above solution works perfectly but I choose to add the following code for them willing to get the clicked option. It allows you get the selected option even when this select value has not changed. (Tested with Mozilla only)
First create a
select option
. After that usingjquery
you can get current selected value when user changeselect option
value.Another and short way to get value of selected value,