<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 somewhere in the document. An alert box will alert the tag name of the element you clicked on.</p> <h3>This is a header</h3> <p>This is a paragraph</p> <img border="0" src="http://www.w3schools.com/JS/ball16.gif" width="29" height="28" alt="Ball"> </body> </html>
Edit the text above, and click on the button to see the result.
Copyright © 2007-2008, Www.JavaBasics.We.Bs All rights reserved.