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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:08:25+00:00 2026-05-15T12:08:25+00:00

How does the click() function in jquery work when working with multiple stacked divs?

  • 0

How does the click() function in jquery work when working with multiple stacked divs?

I have one main div and another div inside of the main div, when i click on the div inside, its also considered a click on the main div, but i dont want that, i want it to only consider a click on the inside div.

<div id="main"><div id="inner"></div></div>

Lets say the main div is a lot larger and the innner div is just a small square, when i click on the inner div(small square) I dont want it to trigger anyting as if i were to click on the main div. How do I maneuver this? Thanks again!

  • 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-15T12:08:26+00:00Added an answer on May 15, 2026 at 12:08 pm

    Events bubble up from the one that was clicked, through all its ancestors. Any ancestor that handles that event will have its handler fired.

    What you need to do is to call event.stopPropagation() in order to prevent the event from bubbling up to its ancestor elements.

    $('#inner').click(function(evt) {
        evt.stopPropagation();
        // your code
    });
    
    • http://api.jquery.com/event.stopPropagation/

    Another alternative is to return false; at the end of your handler.

    $('#inner').click(function(evt) {
        // your code
        return false;
    });
    

    You can test it out here: http://jsfiddle.net/ZpeYr/

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

Sidebar

Related Questions

Does anyone see why this jquery click function would not work? It is not
I have a problem of jQuery's live() function not working with click, mousedown but
$('.nav').bind('click',alert(0)); and: $('.nav').bind('click',function(){alert(0)}) Why does only the second command work?
following up from yesterday... This portion of the code does work. $(document).ready(function(){ $('#listMenu a').click(function
I click on a link from one page that does a redirect to another
The following code does not submit the input values: $('.button').live('click', function() { var date
Why does FramedCloud popup steal click events inside the popup? current_popup = new OpenLayers.Popup.FramedCloud(
I am loading a set of images from another page using jquery load() function.
<?php echo(var answersC = answer-table-$qrow->id;); echo(var toggleC = toggle-table-$qrow->id;); ?> jQuery('toggleC').click(function() { jQuery('answersC').slideToggle('fast'); });
I have some code where you click on a link and jQuery opens a

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.