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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:19:36+00:00 2026-05-28T00:19:36+00:00

Html <div class=lang-currency-field> <div class=lang-currency-links>links here</div> </div> jQuery <script> $(‘.lang-currency-button’).click(function() { $(‘.lang-currency-field’).fadeIn(); }); $(‘.lang-currency-links’).click(function()

  • 0

Html

<div class="lang-currency-field">
   <div class="lang-currency-links">links here</div>
</div>

jQuery

<script>    
     $('.lang-currency-button').click(function() {
         $('.lang-currency-field').fadeIn();
     });    

     $('.lang-currency-links').click(function() {
        $('.lang-currency-field').fadeOut();
     });    

     $('.lang-currency-field').outside('click', function(){
         $('.lang-currency-field').fadeOut();
     });    
</script>        

I’ve read many articles and forums here on stackoverflow but I can’t sort this out for some reasons.

How can I close/fadeOut the lang-currency-field div by clicking somewhere on the page?

It closes fine when I click on one of the links but not when I actually click out of the div.

Could you help me please? Thank you.

  • 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-28T00:19:37+00:00Added an answer on May 28, 2026 at 12:19 am

    I would suggest a handler on the div that prevents event bubbling and then delegate the “outside” handler to the document. The handler on the div prevents clicks within the div, but not on a link from having the document-level handler close the div. Note: you’ll need to be careful of other handlers for the page that they either allow clicks to bubble up to the document (if outside the div you’re closing), they take care of closing the div as well, or they take you to another page entirely (so that the div doesn’t need to be closed). If you stop propagation in handlers for elements outside the div, then the document-level handler won’t be invoked.

    <script>
         $(function() { // this will make sure the relevant DOM elements are loaded first   
            $('.lang-currency-button').click(function(e) {
                e.stopPropagation(); // because we don't want to close immediately after opening
                $('.lang-currency-field').fadeIn();
            });    
    
            $('.lang-currency-links').click(function(e) {
               e.stopPropagation(); // prevent bubbling since we don't need other handlers.
               $('.lang-currency-field').fadeOut();   
            });    
    
            $('.lang-currency-field').click(function(e){
                e.stopPropagation(); // prevent bubbling to document handler so div stays open when clicked inside, but not on a link
            });
    
            $(document).click(function() {
                $('.lang-currency-field').fadeOut();
            });
         });  
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is link to an example: http://techchorus.net/demos/jquery/hiding-input-elements-in-a-div.html It actally disables few elements on click
How can I get DIV id or DIV class using Jquery if the HTML
$('div.box').html(hello) puts the word hello inside all my div's of class 'box'. They all
Is this html <div class='title centered'>SCE</div> <div class='description'> Magna tristique pulvinar porta montes, scelerisque
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
The HTML: <div id=timerList> ... <li rel=project class=open> <a class= style= href=><ins>&nbsp;</ins>Project C</a> </li>
following is my code HTML : <div id = content > <div class =
Suppose the following HTML div container <div id=container> <form> <div> <label class=error>Name</label> <input type=text
in jQuery statement: $.get(someurl, function (data) { ### }); I receiving something like: <div
Hi I have HTML like this <div class=header_countrys_middle> <a href=http://www.test.com title=United States><img src=/images/flags/us.gif alt=us

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.