Reputation: 2067
I was told that an 'event object' gets passed as a parameter to the function in the program below. What would an example of an 'event object' be? Is it, for example, the <p>
element if you clicked on a <p>
or <html>
if you clicked on <html>
, or is the event object the actual 'click'?
document.addEventListener('click', function(e){
console.log(e.target.nodeName);
},false);
Upvotes: 4
Views: 6850
Reputation: 1
in html code you can use by example:
<input type="text" onchange="show(this)" />
<script>
show(e) {alert(e.value);}
</script>
best regards!
Upvotes: 0
Reputation: 285047
It's roughly the actual click. See the thorough MDC documentation for event and MouseEvent. You can get the target element from event.target.
Upvotes: 4