event propogation Jquery

Posted on 2012-09-13
Last Modified: 2012-09-13
          $('#submenuDiv').click(function (e) {
$("body").click(function () {

Open in new window

snippet of code in my $(document).ready(function is shown above.
div.submenuDiv is contained in div.resultsDiv. I put a breakpoint at e.stopPropogation and also within the $("body").click function.

when I click within the div.submenuDiv then both the breakpoints get hit. why? should the e.stopPropogation not allow the second breakpoint from being hit?
Question by:sanagarwl
    LVL 42

    Assisted Solution

    by:Chris Stanyon
    You've got a typo in your code. It should be:

    LVL 42

    Accepted Solution

    Also, in your question you say you have a 'div.submenuDiv' - this is a DIV with a class of submenuDiv, yet in your jQuery code, you are attaching the click event to an element with an ID of submenuDiv

    #submenuDiv - ID
    .submenuDiv - Class

    Author Closing Comment

    thank you. couple of typos - sorry about that. the div.submenuDiv is incorrect - both are ids

    e.stopPropagation worked - I put in a false and that was working just fine which is a combination of e.preventDefault and e.stopPropagation.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question ( on how to make a page show some balloons animate up a page…
    In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now