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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:35:13+00:00 2026-05-23T03:35:13+00:00

I have a containing div, which acts as a button all by itself… When

  • 0

I have a containing div, which acts as a button all by itself…

When clicked though, I have it setup to expand and reveal more information, at the same time revealing a close button on the top right…

Now, When i click the close button, the close function executes, but also the div’s onclick to open, so the end result is, well… Nothing happens…

Lol…

The fiddle example isn’t working either, and I’m near the end of my wits…

http://jsfiddle.net/VeyeY/5/

  • 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-23T03:35:14+00:00Added an answer on May 23, 2026 at 3:35 am

    You could either return false from the onclick to close the div. That will make sure that the click event is not propagated.

    Another solution would be to call preventDefault() and stopPropagation() on the event itself. That will also make sure that the event does not go on.

    Edit:

    In all the Events that happens ( onclick, onchange, onmouseover, etc ) there is always an event variable possible that you can either ignore if you want to, or extract information from. In your example I think the easiest way to work with the event variable would be to do something like this:

    <div id="inner" onclick="toggle(false); event.preventDefault(); event.stopPropagation();">
    

    Now this is a bit ugly to look at and you really dont want to deal with this in the html markup either so another option would be to pass the event variable to your function like this:

    <div id="inner" onclick="toggle(event, false)">
    

    and then in the javascript:

    function toggle(event, x){
        // Do your thing
    
        event.preventDefault();
        event.stopPropagation();
    }
    

    There are a lot of things you could do with the event variable. For example, instead of passing true or false to your function, you could check which node that originated the event like this:

    if(event.originalTarget.id == "inner"){
        // Inner was clicked
    }else if(event.originalTarget.id == "outer"){
        // Outer was clicked
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an absolutely positioned div containing several children, one of which is a
I have div containing a list of flash objects. The list is long so
Say I have a div containing an unlimited number of child div s. Is
I have a fixed width DIV containing a table with many columns, and need
This is the problem. I have an div which includes a few paragraphs of
I have a setup like this: <div class=item> <img src=.../> <span class=item-detail></span> <span class=item-detail></span>
I have a simple jquery animation on a div, which is inside a div,
I have a simple textarea which works in all browsers i.e. I can click
I have DataTemplate containing a TextBox . I'm setting this template to a listbox
I have a column containing the strings 'Operator (1)' and so on until 'Operator

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.