Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

convert nav links to <select>

View nav2select.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
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.