I need to append an option between two options.I have found so many answers regarding appending an option using jquery.But there the option is appending to the last.But i need to be between two options.
I need to insert the new option between 2 & 3. How can I do it?
$(document).ready(function() {
var option = $('<option disabled="disabled" value="">-------------------------</option>');
$('#country').append(option);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="country">
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
</select>