Reply
Wed 3 Feb, 2016 04:37 pm
I have a drop down script that works well, it shows a default (" go to...) and I want it to show the current selection or page that they are on.
// DOM ready
$(function() {
// Create the dropdown base
$("<select />").appendTo("navP");
// Create default option "Go to..."
$("<option />", {
"selected": "selected",
"value" : "",
"text" : "Jump To..."
}).appendTo("navP select");
// Populate dropdown with menu items
$("navP a").each(function() {
var el = $(this);
$("<option />", {
"value" : el.attr("href"),
"text" : el.text()
}).appendTo("navP select");
});
// To make dropdown actually work
$("navP select").change(function() {
window.location = $(this).find("option:selected").val();
});
});