JavaScript event object?

I was told that the "event object" is passed as a function parameter in the program below. What could be an example of an “event object”? Is this, for example, an element <p>if you clicked on <p>or <html>, if you clicked on <html>, or is this an actual 'click' event object?

document.addEventListener('click', function(e){
console.log(e.target.nodeName);
},false);
+3
source share
2 answers

This is roughly the actual click. See Complete MDC Documentation for event and MouseEvent . You can get the target element from event.target .

+4
source

in html code you can use an example:

<input type="text" onchange="show(this)" />

<script>
  show(e) {alert(e.value);}
</script>

Regards!

0

All Articles