This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

distinguish between a click on the background of an element

 
Pesho Petrov
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

I have the following problem here - in my HTML I have a LI tag, which holds other tags inside(img div-s, hyperlinks).
My desire is to call a JavaScript function, but only when the background of LI is clicked. For example if a link within the LI tag is clicked, then the corresponding link is followed.

I tried adding the function directly in the LI but then it executes no matter what I click within this tag.


Please let me know if it's possible to isolate only the background clicks.

Thanks!
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look into using cancelBubble of the links and other things inside the element.

Eric
 
Pesho Petrov
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Eric,

This was exactly what I was looking for ! ! !


many thanks,
Pesho
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic