0
   

drop down script

 
 
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();
});

});
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 525 • Replies: 0
No top replies

 
 

Related Topics

 
  1. Forums
  2. » drop down script
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/23/2024 at 06:40:53