Bootstrap dropdown : How change the icon class on page refresh/reload?

I’m using the Bootstrap framework dropdown as a sort of select. Please see the image bellow:


When the user clicks on each of the dropdown links, a js function is fired to set a cookie defining the user’s city/region. -> This is working!

The same function adds a new class to the icon of the clicked link within the dropdown to indicate the selected item/city (see the “green dot icon” in the image above). -> This works as soon as the click is triggered!


The function fails to keep the icon new css class after the page reloads, and both links are displayed with the grey dot icon. -> Fail!

Here’s the html:

<a href="#" id="city_1'" class="define-city-1" data-city="city1" role="menuitem">
<i class="icon large-point grey-300" aria-hidden="true"></i>

And the js

function reload_city() {
	setTimeout(function() {	
		window.location = '/?city=' + jQuery.cookie('city');
	}, 1000);


	jQuery.cookie('city', jQuery(this).attr('data-city'));

	if(jQuery(this).attr('data-city') == jQuery.cookie('city')){



I was wondering what causes this behavior on page reload, and I’d really appreciate any inputs regarding this issue. Thanks in advance!

Better to try