Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <head> <script> function whichElement(e) { var targ; if (!e) { var e = window.event; } if (e.target) { targ=e.target; } else if (e.srcElement) { targ=e.srcElement; } var tname; tname = targ.tagName; alert("You clicked on a " + tname + " element."); } </script> </head> <body onmousedown="whichElement(event)"> <p>Click somewhere in the document. An alert box will alert the name of the element you clicked on.</p> <h3>This is a heading</h3> <img border="0" src="smiley.gif" alt="Smiley" width="32" height="32"> <p>This is a paragraph.</p> </body> <!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjs_events_srcelement by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 07:37:17 GMT --> </html>
Result:
Try it Yourself - © w3schools.com