I usually have the code something like this:
HTML CODE:
<select id="mySelectOne">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
JS CODE:
$("#mySelectOne").on("change",function(){
var value = $(this).val(); // Return the value selected
alert(value);
});
Using Arrow Function:
$("#mySelectTwo").on("change", () => {
var value = $(this).val(); //"this" is undefined
alert(value);
});
DEMO: https://jsfiddle.net/cmedina/kr1hxxtm/
When I use arrow function the value of this
is undefined
(Should refer to select element).
How can I pass the parameter?