Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8609579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:54:51+00:00 2026-06-12T03:54:51+00:00

I found a nice script for dropdowns. The thing is, I’m trying to have

  • 0

I found a nice script for dropdowns. The thing is, I’m trying to have multiple dropdowns on the same page, but use the same class so I don’t have to duplicate the styles.

The script is form here:

http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.aspx

I’ve downloaded the code and tried adding two on a page but when clicking on one of them, it triggers both. I’ve tried several things with .parent(), .children() etc but nothing has worked.

Could anyone help and point me in the right direction? Here’s the demo page where the source code can be seen:

http://www.jankoatwarpspeed.com/examples/reinventing-drop-down/

UPDATE:
And here’s is a copy of that demo page I was working on: http://multideveloper.com/tests

Thanks a million!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:54:53+00:00Added an answer on June 12, 2026 at 3:54 am

    This is because the drop down component assumes there is only one instance and binds to it by the class name.

    With a few changes in the script, you can get multiple instances working. The summary of changes are below.

    Demo: http://jsfiddle.net/fZbx6/1/

    I’ve put in comments to highlight the changes.

    $(document).ready(function() {
        $(".dropdown img.flag").addClass("flagvisibility");
    
        $(".dropdown dt a").click(function() {
    
            // old
            //$(".dropdown dd ul").toggle();
    
            // new
            $(this).parents(".dropdown").find("dd ul").toggle();
    
        });
    
        $(".dropdown dd ul li a").click(function() {
            var text = $(this).html();
    
            // old
            //$(".dropdown dt a span").html(text);
            //$(".dropdown dd ul").hide();
    
            // NEW
            var dd = $(this).parents(".dropdown");
            dd.find("dt a span").html(text);
            dd.find("dd ul").hide();
    
            $("#result").html("Selected value is: " + getSelectedValue("sample"));
        });
    
        function getSelectedValue(id) {
            return $("#" + id).find("dt a span.value").html();
        }
    
        $(document).bind('click', function(e) {
            var $clicked = $(e.target);
            if (! $clicked.parents().hasClass("dropdown"))
                $(".dropdown dd ul").hide();
        });
    
    
        $("#flagSwitcher").click(function() {
            $(".dropdown img.flag").toggleClass("flagvisibility");
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found a nice script to import xml using powershell http://slash4.de/tutorials/Automatic_mediawiki_page_import_powershell_script Currently I don't
I have found a nice jquery increment script. The increment portion can accept a
I'm new to JavaScript. Found nice calendar script, but without month switch buttons. I
I'm looking for nice loading indicators for Silverlight. I found a few, but all
I just found out about yield return , I seems really nice. I use
I found a nice little script on snippr( http://snipplr.com/view.php?codeview&id=799 ) that gives me the
I am trying to use Jquery Dialog box in place of Java script standard
I have found a script that adds mouse trail on Opera's mouse gesture. Very
I have this nifty little script that does a nice job of manipulating some
I have this script: http://jsfiddle.net/NV2uV/ It works, but I do not like it. Cons:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.