javascript prevent value change in select option

Solutions on MaxInterview for javascript prevent value change in select option by the best coders in the world

showing results for - "javascript prevent value change in select option"
Jana
22 Nov 2020
1old_value = $('#select :selected').val();
2$('#select').change(function() {
3  if($(this).val() == 'option 3') {//your specific condition
4     $('#select').val(old_value);
5  } else {
6    old_value = $('#select :selected').val();
7  }
8});