Mega Code Archive

 
Categories / JavaScript DHTML / Event
 

Which element was clicked

<html> <head> <script type="text/javascript"> function whichElement(event){     var tname     tname=event.srcElement.tagName     alert("You clicked on a " + tname + " element.") } </script> </head> <body onmousedown="whichElement(event)"> <p>Click in the document. </p> <h3>This is a header</h3> <p>This is a paragraph</p> <img border="0" src="http://www.rntsoft.com/style/logo.htm"      width="50" height="50" alt="Ball"> </body> </html>