JSFiddle - React, Tailwind, and code Playground
HTML
<select id="mySelect">
<option>Foo0</option>
<option seleted="selected">Foo1</option>
<option>Foo3</option>
<option>Foo4</option>
<option>Foo5</option>
<option>Foo6</option>
</select>
JavaScript
jQuery(document).ready(function($){
var index = $('#mySelect').prop('selectedIndex');
var select = $('#mySelect');
select.change(function(e){
alert(index)
var conf = confirm('Are You Sure?');
if(!conf){
$('#mySelect').prop('selectedIndex',index);
// reset the select back to previous
return false;
}
else{
index= $('#mySelect').prop('selectedIndex');}
// do stuff
});
});