Javascript examples for DOM Event:onclick
Finding the source of a click in event bubbling with event srcElement and originalTarget
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* ww w .ja v a 2 s. c om*/ document.getElementById('buttons').onclick = function (evt) { var source = evt.srcElement || evt.originalTarget console.log(source.id); } } </script> </head> <body> <div id="buttons"> <button id="btn1">1</button> <button id="btn2">2</button> </div> </body> </html>