click on link should not trigger parental onclick-event

ViagraBestellen

New Member
I've got the following code:\[code\]<div onclick="alert('div event');" style="cursor:pointer"> some text <a href="http://stackoverflow.com/questions/5590944/asd.php" id="link">click</a></div>\[/code\]When somebody clicks on the link the javaschipt event is triggered. I want that the event is only triggers if somebody clicks on the text or on the empty space inside the div container; and not if somebody clicks on the link.Is it possible to call a function when the event is triggered, which checks on which elements the user has clicked. something link\[code\]onclick="foo(caller);"\[/code\]and\[code\]function foo(element){ if(element!='link'){ alert('yes'); }} \[/code\]
 
Top