Javascript examples for DOM:Element tagName
Element tagName Property - Using the tagName property together with the event.target property to find out which element triggered a specified event:
<!DOCTYPE html> <html> <body onclick="myFunction(event)"> <p>click me</p> <h1>This is a heading</h1> <button>This is a button</button> <span>A span element</span> <p id="demo"></p> <script> function myFunction(event) {/* w w w.j av a 2 s. c om*/ var x = event.target; document.getElementById("demo").innerHTML = "Triggered by a " + x.tagName + " element"; } </script> </body> </html>