I'm trying to convert a menu to a dropdown for use in the mobile-version
I found a website where it explained how to convert a menu into drop down and I succeeded in having the drop down in the page, but the problem I have is that the JavaScript doesn't work. Clicking different options doesn't change the page.
HTML:
<nav>
<nav id="menu">
<ul>
<li><a href="indexoriginal.html">Home</a></li>
<li><a href="#">Bio</a>
<ul>
<li><a href="aboutme.html">Biography</a></li>
<li><a href="repertoire_english.html">Repertoire</a></li>
</ul>
</li>
<li><a href="#">Gallery</a>
<ul>
<li><a href="media.html">Media</a></li>
<li><a href="photosgeneral.html">Photos</a></li>
</ul>
</li>
<li><a href="agenda_english.html">Agenda</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
<select>
<option value="/" selected="selected">Home</option>
<option value="aboutme.html">Biografía</option>
<option value="repertoire_english.html">Repertorio</option>
<option value="media.html">Media</option>
<option value="photosgeneral.html">Fotos</option>
<option value="agenda_english.html">Agenda</option>
<option value="contact.html">Contact</option>
</select>*
</nav>
And here is the JavaScript I put in the of the html document:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
</script>
<script>
//DOM ready
$(function(){
// Create the dropdown base
$("<select />").appendTo("nav");
// Create default option "Go to..."
$("<option />", {
"selected": "selected",
"value" : "",
"text" : "Go to..."
}).appendTo("nav select");
// Populate dropdown with menu items
$("nav a").each(function() {
var el = $(this);
$("<option />", {
"value" : el.attr("href"),
"text" : el.text()
}).appendTo("nav select");
});
$("nav select").change(function() {
window.location = $(this).find("option:selected").val();
});
</script>
And the webpage whose code I'm referencing: https://css-tricks.com/convert-menu-to-dropdown/