Skip to content

Instantly share code, notes, and snippets.

@zlojkashtan
Forked from h4/t.js
Created August 11, 2017 12:28
Show Gist options
  • Save zlojkashtan/0f8fe90e137a4a360f2c089c2aaebd77 to your computer and use it in GitHub Desktop.
Save zlojkashtan/0f8fe90e137a4a360f2c089c2aaebd77 to your computer and use it in GitHub Desktop.
$(function() {
var $citySelect = $('#city-select'),
STORAGE_ITEM_NAME = 'saveCity';
$citySelect.on('change', function () {
var url = $citySelect.val();
if (url !== '') {
localStorage.setItem(STORAGE_ITEM_NAME, url);
window.location = url;
}
return false;
});
if(localStorage.getItem(STORAGE_ITEM_NAME)){
$citySelect.val(localStorage.getItem(STORAGE_ITEM_NAME));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment