jQuery
Get the selected country and then find the <option>
using attribute-equals-selector and hide the siblings
$(function () {
var country = $('.selected').data('country');
$('#CountryCode').find('[value="' + country + '"]').siblings().hide();
$('#CountryCode').val(country);
});
HTML
Add data-*
attribute to the html elements
<ul>
<li data-country="ARG">Argentina</li>
<li data-country="USA" class="selected">United States</li>
<li data-country="AUS">Australia</li>
</ul>
1
solved How to filter a dropdown list based on a already pre selected list