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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:06:58+00:00 2026-06-15T19:06:58+00:00

I have two divs. Clicking on the first toggles the second with jquery show

  • 0

I have two divs. Clicking on the first toggles the second with jquery show when ever a user clicks anywhere on the div ‘body’ div.

My problem is this, when a user clicks on a link in the ‘body’ div, the show executes before the link loads. It creates confusion for users who think they missed something on the last page. Is it possible to create a simple exception for links within the ‘body’ div?

<div>
      <div class="body">
         <p>Some really good links</p>
         o Example Org: <a href="http://example.org">example.org</a><br>
         o Example Dotcom: <a href="http://example.com">example.com</a>
      </div>
      <div class="toggle" style="display: none;">
         <p>Some really detailed information here.</p>
      </div>
</div>

My javascript is like so:

<script>
$(document).ready(function () {
  bindToggle;
});

function bindToggle() {
    $(".toggle").hide();
    $(".body").click(function(event) {
        el = $(this).next();
        if (el.is(":visible")) {
            el.hide('fast');
        } else {
            el.show('fast');
        }
    });
};
</script>

Here is a demo: http://jsfiddle.net/esJsP/3/

  • 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-15T19:06:59+00:00Added an answer on June 15, 2026 at 7:06 pm

    Calling event.stopPropagation on click of link in body stops the event from reaching to body. Add below code and check the output:

    $('.body > a').click(function(e) {
        e.stopPropagation();
    });
    

    Here is a demo: http://jsfiddle.net/esJsP/5/

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

Sidebar

Related Questions

I have two divs: <div class=outer> <div class=inner>Example</div> </div> And I have a jQuery
I have two divs float:left. I z-index the first div to be above, but
I have two html files namely FIRST.html and SECOND.html FIRST.html has DIVs with IDs
I have two DIVs, #placeholder AND #imageLoad. When the user clicks on a particular
I have two divs floated next to one another: <div id=parent> <div id=child_1 style=float:left>
I have two divs: <div class=dialog large></div> and <div class=dialog></div> I have to remove
I have two divs one inside another, i would like to overlap one div
I have two divs. I would like to move/populate the text from div id
Possible Duplicate: click link below a higher z-index div I have two divs, one
I have two divs as follows: <div class=car-service id=browse-all-button> <p>CAR SERVICE</p> <span>56 Race Ramps</span>

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.