I am trying to set a variable in jQuery. The value is supposed to be set on the click event of the button. The onclick event fires but the x10Device variable remains u
u
You can change the selector and data attributes as you wish!
Mazda Honda Mercedes Toyota $("#selectVehicle").change(function () { alert($(this).find(':selected').data("year")); });
Here is the working example: https://jsfiddle.net/ed5axgvk/1/