I am building a dropdown menu for my mobile view of my site. When the user selects an option it goes to a new url that has information specific to that choice, however I need the option to have the selected value afterwards, as it is currently showing the wrong option after the page loads
HTML:
<select class="location-choices">
<option id="subnav_Dallas" class="li1 first_child">Dallas</option>
<option id="subnav_Atlanta" class="li1 active">Atlanta</option>
<option id="subnav_Denver" class="li1" selected="">Denver</option>
<option id="subnav_Indianapolis" class="li1">Indianapolis</option>
<option id="subnav_San Jose" class="li1">San Jose</option>
</select>
JQuery:
$('.location-choices').on('change', function () {
// drop down for locations
// bind change event to select
var url = "/locations-hours/" + $(this).val(); // get selected value
url = url.replace(' ', '-');
window.location = url; // redirect
$('.location-choices1 option[href^="/locations-hours/' + location.pathname.split("/")[1] + '"]').addClass('active'); //set the dropdown to active
});
});