?
Solved

event propogation Jquery

Posted on 2012-09-13
3
Medium Priority
?
607 Views
Last Modified: 2012-09-13
          $('#submenuDiv').click(function (e) {
          e.stopPropogation();
});
$("body").click(function () {
       $("#resultsDiv").hide();
       $("#resultsSchoolListDiv").find(".dropdownSchoolList").hide();
       $("#resultsSchoolListDiv").hide();
}); 

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?
0
Comment
Question by:sanagarwl
  • 2
3 Comments
 
LVL 45

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 2000 total points
ID: 38395774
You've got a typo in your code. It should be:

e.stopPropagation();
0
 
LVL 45

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 38395780
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
0
 

Author Closing Comment

by:sanagarwl
ID: 38395820
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

840 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