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 6996013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:06:10+00:00 2026-05-27T20:06:10+00:00

Ok i have this drop down menu script. It works fine when all the

  • 0

Ok i have this drop down menu script. It works fine when all the clicking takes place on the menu itself but when i click off of the menu the drop down does not close. I want the menus to close if the user clicks somewhere on the screen that is not the actual menu.

I have tried adding the code:

document.onclick = ddMenu_close;

But then this makes the menu never open because it is calling “open” through the function but then closing it right away because it then calls the onclick ddMenu_close. My script is below:

<script type="text/javascript">
  function ddMenu() {
    var timeout    = 500;
    var closetimer = 0;
    var ddmenuitem = 0;

    function ddMenu_open(e)
    {
       ddMenu_close();
       var submenu = $(this).find('ul');
        if(submenu){
            ddmenuitem = submenu.css('visibility', 'visible');

        }

    }

    function ddMenu_close()
    {  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden'); }

    function ddMenu_timer()
    { closetimer = window.setTimeout(ddMenu_close, timeout); }

    function ddMenu_canceltimer()
    {  if(closetimer)
       {  window.clearTimeout(closetimer);
          closetimer = null;}}

    $(document).ready(function()
    {  $('#ddMenu > li').bind('click', ddMenu_open);
       $('#ddMenu li ul').bind('click', ddMenu_timer);


    });


    }
    </script>

So i need to add something to this script that will close the drop down when the ducument or window is clicked but not interferer with the clicking on the menu or the drop down. Thank you for any help.

  • 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-05-27T20:06:11+00:00Added an answer on May 27, 2026 at 8:06 pm

    In ddMenu_open () for $(document) binding click event trigger ddMenu_close ().
    In ddMenu_close () cancel $(document) of the click event.

    this is the example:

    http://jsfiddle.net/bEPvP/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a drop down menu which works fine but i want to
So, basically I have this select / drop down menu that I use AJAX
Good Morning, I have a really simple script that works fine on everything but
I have a simple drop-down menu that is controlled using the following script: $(document).ready(function
I have a drop down like this on my page: <p> <%= f.label :episode_id
This would be my issue I have a drop down that's not displaying fully.
I have this sql: ALTER TABLE dbo.ChannelPlayerSkins DROP CONSTRAINT FK_ChannelPlayerSkins_Channels but apparently, on some
i have built jQuery drop-down menu which is having problems floating over the UI
I have a drop down menu that is coded in HTML, CSS, and jQuery
I have a jQuery 1.5+ script, and you select a quantity in a drop-down

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.