<input type="button" id="btn" value="Click me" onclick="check();"/> <script> function check() { var e = window.event; var obj = e.target||e.srcElement; alert(obj.id); } </script>