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

The Archive Base Latest Questions

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

I have a script here, and it works amazing, except for one small detail.

  • 0

I have a script here, and it works amazing, except for one small detail. It basically runs as click function that fades in and out certain DIVs on the click of a link.

The problem is, however, that when you click ANYWHERE on the page, it removes the DIV and leaves an empty content area until you click one of the links. Obviously this is a problem.

I can’t use the exact code I’m using for NDA reasons, but here is same setup I am using with just some plain text in the divs.

Just click the links to see the functionality, and then click anywhere else on the page (in the div, in the white space, whatever) and watch the div just disappear. I’m know that that is what the JavaScript is calling, but I don’t know how to disable the click in the divs so this doesn’t happen. Also, how to do that so it doesn’t disable the link that are within that div.

Any help is greatly appreciated. This website is a life saver.

This is the original code I got off of this site edited to show my very basic layout. Basically a bunch of links that are inline and when clicked, they change a section of DIVS to another section of divs:

<html>

<head>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    var gLastH = null;
    var gLastId = null;

    $('.toggle').click(function(e) {
        $('.toggleh:visible').fadeOut('slow');
        gLastId = $(this).attr('id');
        console.log('#' + gLastId + 'h');
        gLastH = $('#' + gLastId + 'h');
        $(gLastH).fadeIn('slow');
        e.stopPropagation();
    });

    $('*').click(function(e) {
        if ($(this).attr('id') != gLastId) {
            $(gLastH).fadeOut('slow');
        }

        e.stopPropagation();
    });
});
</script>

</head>

<body>
<div id="menubar">
    
    <a href="#" onclick="return false;" class="toggle" id="toggle1" style="display: inline;">
        text here</a>
    <a href="#" onclick="return false;" class="toggle" id="toggle2" style="display: inline;">
        text here</a>
    <a href="#" onclick="return false;" class="toggle" id="toggle3" style="display: inline;">
        text here</a>
    <a href="#" onclick="return false;" class="toggle" id="toggle4" style="display: inline;">
        text here</a>

    <div class="toggleh" id="toggle1h">
        some description in here I suppose
    </div>
   
    <div class="toggleh" id="toggle2h" style="display: none;">
        some description in here I suppose #2dsfds  sdfdsfa sdf 
    </div>
  
    <div class="toggleh" id="toggle3h" style="display: none;">
        some description in here I suppose #3dffdfasdfdsfdfasf
    </div>
   
    <div class="toggleh" id="toggle4h" style="display: none;">
        some description in here I suppose #4 dfdafa
    </div>
</div>

</body>

</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-28T04:58:08+00:00Added an answer on May 28, 2026 at 4:58 am

    $('*').click(... sets up a click handler for ALL elements (*). You can remove this function.

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

Sidebar

Related Questions

I have script like this : $(#addk).bind(click, function(event){ //alert(here!); $(#loader-overlay).show(); $.ajax({ 'async':False, 'type': POST,
I have this script that works ok. Trouble is that when I make Click
I have this simple function: <script type=text/javascript> //<![CDATA[ jQuery(function($){ function here(b){alert(b);} ; here(6); });
I'm writing a script that will ping my ip range. Here's what I have
Just wondering what little scripts/programs people here have written that helps one with his
Basically I have a script in Python that grabs the text from an open
I have got a script here that animates a div changing height, then after
I am having a bizare problem where I have a script that works elsewhere
Here is what I am trying to do. I have a perl script that
I have a script partially based on the one here: Upload files with FTP

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.