event.type property
The event.type property contains
the type of an event that occurred.
Syntax
event.type;
Example
In the following example, a click handler
is attached to an element, so the event
type will be 'click':
<button id="elem">button</button>
let elem = document.querySelector('#elem');
elem.addEventListener('click', function(event) {
console.log(event.type);
});
The code execution result:
'click'
Example
In the following example, a focus loss
handler is bound to an input, so the
event type will be 'blur':
<input id="elem">
let elem = document.querySelector('#elem');
elem.addEventListener('blur', function(event) {
console.log(event.type);
});
The code execution result:
'blur'