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

  • Home
  • SEARCH
  • 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 7050441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:08:38+00:00 2026-05-28T03:08:38+00:00

I have a text input, and a hidden list. The list will show and

  • 0

I have a text input, and a hidden list. The list will show and hide upon focusing and blurring the input. However, I want the list remain showing when I click on the list (outside the input), i.e., only hide the list when click on outside of it. How to achieve that?

==== html ====

<input type="text" id="regioninput">
<ol class="continentlist">
  //php code to generate list items
</ol>

==== js ====

$('#regioninput').bind('focus', function() {
    $('.continentlist').show();
});
$('#regioninput').bind('blur', function() {
    $('.continentlist').hide();
});
$('.continentlist li').live('click', function() {
    alert($(this).html());
    ...
});
  • 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-28T03:08:39+00:00Added an answer on May 28, 2026 at 3:08 am

    You can change your code a bit so instead of using blur and focus you can just use click on different elements:

    //show the list when you click the input
    $('#regioninput').bind('click', function(event) {
        event.stopPropagation();
        $('.continentlist').show();
    });
    
    //hide the list when the document receives a click
    $(document).bind('click', function () {
        $('.continentlist').hide();
    });
    
    //make sure that if the user clicks on the list they won't hide it
    $('.continentlist').bind('click', function(event) {
        event.stopPropagation();
    });
    

    Here is a demo: http://jsfiddle.net/qUeXS/

    event.stopPropagation() stops the event from bubbling up the DOM: http://api.jquery.com/event.stoppropagation

    On a side-note, this works because of event bubbling. No matter where you click on a document, the document object will receive that click event after it bubbles all the way up the DOM. So if we cancel the bubbling of the event we can stop the document object from receiving the event.

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

Sidebar

Related Questions

I have a text input field like text box or text area. I want
I have text input boxes. There is validation for each of the boxes using
I have one text input and one button (see below). How can I use
I have a text input : <input type=text onkeydown=processText(this) /> I have a processing
I have the following text input on a budget calculator form which displays the
Newbie question... The objective: I intend to have an HTML text input field as
I have this input text: <html><head><meta http-equiv=content-type content=text/html; charset=utf-8></head><body><table cellspacing=0 cellpadding=0 border=0 align=center width=603>
I have two input text boxes which are decimal. The sum of the two
I have an input text field, which has a value something by default, but
I have an input text field which has style: visibility: visible or style: visibility:

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.