Consider a web page that has a select menu with a JavaScript event handler tied to the menu\'s onchange event that when fired reloads the page with a new query string (using the
The snippet from @frakhoffy worked for me, but broke normal select behavior in Chrome. When hitting the page without a selected option, the select was blank even though there is not a blank option in the select. I ended up going with:
$(document).ready(function () {
$('select').each(function () {
var select = $(this);
var selectedValue = select.find('option[selected]').val();
if (selectedValue) {
select.val(selectedValue);
} else {
select.prop('selectedIndex', 0);
}
});
});