Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
convert nav links to <select>
var nav = document.getElementById('nav'),
links = nav.getElementsByTagName('a'),
select = document.createElement('select'),
option = document.createElement('option');
for (var i = 0; i < links.length; i++){
var link = links[i],
_option = option.cloneNode(false);
_option.value = link.href; // Set the option's value to the original link
_option.innerHTML = link.innerHTML; // Set the option's text to the original text
// if this link matches the current URL, add a selected attribute
if( window.location.href == link.href ) {
_option.selected = 'selected';
}
select.appendChild(_option);
};
select.addEventListener('change', function() {
window.location = select.value;
}, false);
nav.parentNode.insertBefore(select, nav);
nav.style.display = 'none';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.