Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Source object.

Status
Not open for further replies.

Phil79

Technical User
Jun 5, 2002
64
GB
Hi guys, hope you can help me, this is tying my brain in knots.

I have a <DIV> element which calls a function using onclick. However, the DIV also contains links, which I want to not call the function when clicked on.

<DIV onClick=&quot;Call the function&quot;>
- Content -
<A href=&quot;URL&quot; onclick=&quot;Don't call the function&quot;></A>
- Content -
</DIV>

Also, these links already have onClick events assigned to them.

This is one way I can think of. The other way (which I'm not sure if it'll work) is that it could call the function, but if the function was called by the A tag, then it just returns.

Any advice or comments here would be gratefully accepted.

Thanks

Phil
 
<script>
function clickFunction(){
var obj_src = window.event.srcElement;
if (obj_src.id == &quot;myDiv&quot;){
alert ('div hit')
}
}
</script>


<DIV onClick=&quot;clickFunction()&quot; id=&quot;myDiv&quot;>
- Content - <br>
<A href=&quot;#&quot; onclick=&quot;alert('alert hit')&quot; id=&quot;myHref&quot;>Href</A><br>
- Content -
</DIV> Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
mikewolf@tst-us.com (Do not email regarding this thread unless requested - I don't check this account regularly)
 
Excellent, cheers for the quick response mate.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top