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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:52:00+00:00 2026-06-08T23:52:00+00:00

I have a search input ( #search_input ) which expands when being focused. Additional

  • 0

I have a search input (#search_input) which expands when being focused. Additional search options pop up that allow me to select specific search options.

The input should contract after it blurs, but only when the blur was triggered outside of the form.

http://jsfiddle.net/zMp9S/

Right now I’m using the following which contracts the search input too early even when I’m just choosing a an option from the search option menu:

$(function() {
    $("#search_input").focus(function(){
        $("#search_input").stop().animate({width: 310}, 200);
        $("#search_options").show();
    })
    $("#search_input").blur(function(){
        $("#search_input").stop().animate({width: 100}, 200);
        $("#search_options").hide();
    })        
});​

Putting focus / blur events on the form doesn’t work.

How can I tell jQuery to only contract #search_input when the blur happens outside the form #search_form ?

  • 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-08T23:52:03+00:00Added an answer on June 8, 2026 at 11:52 pm

    You must bind to the click event of the window, otherwise you’ll be unable to detect if the user is losing the focus of a div (that actually does not have a focus/blur event!)

      $(window).click(function(e) {
            if (e.target.id != 'search_options' && e.target.parentNode.id != 'search_options' && e.target.id != 'search_input') {
                $("#search_input").stop().animate({
                    width: 100
                }, 200);
                $("#search_options").hide();
            }
        });
    

    http://jsfiddle.net/zMp9S/9/

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

Sidebar

Related Questions

I have a little side project where I allow radius search. You input a
I have a search input box that appears upon rollover of a button. Rather
i have a form that have a field which hold query for search and
I have a live search input that shows results and lets you use the
I have a search input text which I'd like to apply a focus() when
I have a search box: <input class=box name=search type=text id=search_input /> And a json_encode
I have an input which searcher's google web and another input to search google
Lets say we have a web page with a search input form, which submits
I have a textbox whose input is being handled by jQuery. $('input.Search').bind(keyup, updateSearchTextbox); When
I have a winform app that prompts the user to input two search parameters.

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.