This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Preventing event propagation  RSS feed

 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some code similar to the following. There is an onclick handler on a div element which contains an embedded anchor element. Clicking on the anchor element always seems to invoke the the div onclick handler. The desired action is to have the browser open the default email editor and return with div element onclick event invoked when a user clicks anywhere inside the div element EXCEPT for the anchor link. Is this possible? The application uses jQuery so I have access to that functionality if jQuery contains some way to achieve the desired action.



Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the click handler you can examine the target of the event and let it propagate if it's an anchor, or do whatever else you want to do if it's not.
 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear! That's exactly what I needed to do.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
151
IntelliJ IDE Java jQuery Mac Mac OS X
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!