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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:38:11+00:00 2026-06-01T18:38:11+00:00

In the below screenshot you will see a large green rectangle. This division is

  • 0

In the below screenshot you will see a large green rectangle. This division is shown when clicking a “My Account” link. It can then be hidden by clicking a “Hide” image.

Screenshot: http://knowwhovotes.com/somecap.JPG

I would like the green division to be hidden if a user clicks anywhere outside of the division. I have tried the blur function but could not get it working properly.

Here is the code I have already:

<script>
$(document).ready(function() {
    $("#my_account_button").click(function() {
        $("#c_fancy").css({'display' : 'block'});
        $("#my_account").slideDown("Slow");
    });
    $("#hide_account").click(function() {
        $("#c_fancy").css({'display' : 'none'});
        $("#my_account").slideUp("Slow");
    });
});
</script>
  • 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-01T18:38:12+00:00Added an answer on June 1, 2026 at 6:38 pm

    First, focus/blur are generally only for input elements. They do not fire for div elements.

    You need to have the div be hidden when you click on the document, but not when you click on the div itself or anything in it. To do this, add a click handler to the document, and then stop clicks on the div from propagating up the DOM tree, like this:

    $(document).ready(function() {
        $("#my_account_button").click(function() {
            $("#c_fancy").css({'display' : 'block'});
            $("#my_account").slideDown("Slow");
        });
        $("#hide_account").click(function() {
            $("#c_fancy").css({'display' : 'none'});
            $("#my_account").slideUp("Slow");
        });
    
        $(document).click(function() {
            $("#c_fancy").css({'display' : 'none'});
            $("#my_account").slideUp("Slow");
        });
        $("#c_fancy").click(function(e) {
            e.stopPropagation();
        });
    });
    

    You probably then want to consolidate and put the hide code in a common function:

    $(document).ready(function() {
        $("#my_account_button").click(function() {
            $("#c_fancy").css({'display' : 'block'});
            $("#my_account").slideDown("Slow");
        });
    
        function hideAccount() { 
            $("#c_fancy").css({'display' : 'none'});
            $("#my_account").slideUp("Slow");
        }
    
        $("#hide_account").click(hideAccount);
        $(document).click(hideAccount);
    
        $("#c_fancy").click(function(e) {
            e.stopPropagation();
        });
    });
    

    I do notice that the content behind the div is darkened. This could cause problems if this darkening overlay is part of your #c_fancy element. If so, you need to change your code a bit. Basically, you would need to change the above code from $(document) to $('#myOverlay'), substituting #myOverlay appropriately of course.

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

Sidebar

Related Questions

I have an Adorner which adornes a Border (please see screenshot below). The MouseDown
Screenshots Below. As you can see, my menubutton is showing up in the actionBar's
i will show you an image below but before that... if you have seen
I'm sure this is dead simple, but I can't seem to figure it out.
I've created a blob shape by patching cubic Bezier curves together (screenshot below). I'd
I have a card game (screenshot below) in which I display player avatars. For
Summary So I have 3 tables, which I have screenshots below. Every user will
Please check below screen shot. What is main difference between Master Page and MVC
Below is a question from Kathy & Bert Bates SCJP 5 preparation CD. I
Below I have written a sample program that I have written to learn about

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.