WordPress Menu as Select Dropdown (js)

// Create the dropdown base
$('<div class="mobile-menu"><form><select onchange="if (this.value) window.location.href=this.value" /></form></div>').prependTo("#wrap");
// Create default option "Go to..."
$("<option />", {
"selected": "selected",
"value" : "",
"text" : "Go to..."
}).appendTo(".mobile-menu select");
// Populate dropdown with menu items
$("#nav a").each(function() {
var el = $(this);
$("<option />", {
"value" : el.attr("href"),
"text" : el.text()
}).appendTo(".mobile-menu select");
view raw mobile-menu.js hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk