Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created October 18, 2012 04:42

Revisions

  1. Jared Atchison created this gist Oct 18, 2012.
    22 changes: 22 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    // 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();
    });