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: 410 • Replies: 0
No top replies

 
 

Related Topics

How does one uninstall a program? - Question by Woollcott
Adding a JavaScript 'Copy to Clipboard' - Discussion by BobbyDouglas
JavaScript: OnSelect question - Discussion by neocode
Javascript - Control C textarea script - Discussion by Craven de Kere
2018123 - Question by ibk1995
javascript loops for - Question by vartul agnihotri
 
  1. Forums
  2. » drop down script
Copyright © 2021 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 06/14/2021 at 08:53:03