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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:25:45+00:00 2026-05-22T11:25:45+00:00

I have a small problem identifying an item with jQuery. Let me explain better

  • 0

I have a small problem identifying an item with jQuery. Let me explain better 🙂

I have a menu that appears when the user clicks on a button. This is working perfectly. Then, I want this menu to go away when the user clicks on any part of the site except on the menu. This is also working great, but with a small problem: in the menu, there is an item that allows the user to choose from an autocomplete list. This list was done using jquery-ui autocomplete. When the user clicks on an item here, the menu disappears (it shouldn’t 🙂 ), and I don’t know how to make the exception for this, since I don’t know how can I grab the item, can I grab it by class? Does it have an id?

I have the following code to identify where the click is being done and proceed (you can see that if menu-button or menu are clicked the menu will not hide). How do I make the exception when the click is made in autocomplete of jQuery-ui?

$(document).click(function(event) {
    if($(event.target).parents().index($('#menu')) == -1 && $(event.target).parents().index($('#menu-button')) == -1) {
        if($('#menu').is(":visible")) {
            $('#menu').hide(500);
        }
    }
});

Thanks!

  • 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-22T11:25:46+00:00Added an answer on May 22, 2026 at 11:25 am

    The autocomplete ul has a class of ui-autocomplete. So you can get it by doing $(".ui-autocomplete").

    However, my preferred method for doing what you are trying to do would be to do this:

    $(".ui-autocomplete").click(function(e){
       e.stopPropagation();
       //... and maybe some other stuff
    }
    

    This basically will stop the click from bubbling up, so it will not trigger the document click.

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

Sidebar

Related Questions

I have a small problem where I want to find the next active item
I have a small problem with jQuery $.ajax() function. I have a form where
i have a small problem with a jquery click trigger. in my index.php i
I have a small problem. I have a set of ComboBox's that are bound
I have a small problem that I want to load a url in web
Im new to MVVM and have small problem. I have two user controls: parent
I have a small problem that I don't know how to deal with. I've
I have one small problem regarding MPMoviePlayerController, i have a link that play movie
I have this small problem with jquery: I need to do something like this:
I have a small problem with my jQuery script. <script language=javascript> $(document).ready(function(){ $('.roll-li').click(function(){ if

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.