Source Code:
(back to article)
Submit
Result:
Report an issue
<button id="myButton">Click Me!</button> <div style="margin-top:10px;" id="eventInfo"></div> <script> document.getElementById('myButton').addEventListener('click', function(event) { var eventInfo = 'Event Type: ' + event.type + '<br>Clicked Element: ' + event.target.tagName; document.getElementById('eventInfo').innerHTML = eventInfo; }); </script>