jQuery(document).ready(function($){ | |
// 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"); | |
}); | |
}); |
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.
Other articles in this series
10 ways to speed up your WordPress website
July 17, 2018
A slow website is painful to use, less engaging to visitors, and hurts your search engine rankings. I’ll walk you through the tools I use to identify performance problems, and provide ten tips to improve your website’s performance
Custom recipe templates for WP Recipe Maker
October 7, 2019
I frequently work with food bloggers to improve the design, speed, and functionality of their websites. The recipe card is the most important element on the page. It should be…
Git based code deployment on Big Scoots
February 21, 2020
A guide to setting up git for code deployment on Big Scoots, a popular managed WordPress host.
InnerBlocks with ACF blocks
September 8, 2020
Use InnerBlocks to insert any block (core or custom) inside your custom ACF block. Set the default content, limit which blocks can be used, and more.