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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:42:52+00:00 2026-06-06T14:42:52+00:00

So I am building an input field with an auto-suggest box that suggests content

  • 0

So I am building an input field with an auto-suggest box that suggests content based on the user’s partial input into the field. Kinda like the tags box on stack. The auto-suggest box is absolutely positioned directly below the input field and only appears once the user begins to type text.

I want to make the box disappear when the input field is blurred, that is, when the user clicks anywhere else on the site. Normally, I would just use jquery’s blur() function to hide the auto-suggest box. The problem is that if I do it this way, the user won’t be able to select anything from the auto-suggest box because that would blur the input field and hide the auto-suggest box. I need to find a way to hide the auto suggest box if the user clicks anywhere except for the input field or the auto suggest box. Any ideas how I could set that up using jquery?

Imagine it is setup something like this:

<div id="auto_suggest">
<ul>
<li>Jane</li>
<li>john</li>
</ul>
</div>

<input type="text">
  • 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-06T14:42:53+00:00Added an answer on June 6, 2026 at 2:42 pm

    Use a timeout.

    $("input, #auto_suggest, #auto_suggest a").blur(function() {
       $('#auto_suggest').addClass('hiding');
        setTimeout(function(){
            $('#auto_suggest.hiding').hide();
        },1000);
    }).focus(function() {
       $('#auto_suggest').removeClass('hiding').show();
    });
    
    $('#auto_suggest, #auto_suggest a').focus(function() {
       $('#auto_suggest').removeClass('hiding').show();
    });​
    

    Updated to work well with tabs or clicks:

    http://jsfiddle.net/iambriansreed/vUeeT/

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

Sidebar

Related Questions

I'm building a small app that takes things entered into an input field and
I'm building a LINQ query dynamically based on user input, and I want to
I'm building a blog that should parse bbcode tags like this: Input: <youtube=http://www.youtube.com/watch?v=VIDEO_ID&feature=channel> Output:
I'm building a custom RTE that converts user input to a homebrewn markup, now
I'm building a form where a description field changes it's content based on the
I am building a search box (input field) which should make a server call
I'm building a Jquery/JS filtered data table. I have a search input field that
I am building a autocomplete feature for input text field. Currently I could use
I am building a program that takes an input file in this format: title
I'm building a registration script and I want to insert the user's input (username,

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.