I have a HTML select field. Where one option is selected. If I select any other change even fires and confirm prompt is shown.
What I want is when user cancel the confirmation aka conf is false. I want to reset back to the previous selected option. But currently the new option is selected.
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>
js/jq
jQuery(document).ready(function($){
var select = $('#mySelect');
select.change(function(){
var conf = confirm('Are You Sure?');
if(!conf){
// reset the select back to previous
return;
}
// do stuff
});
});