The Event object also contains the type
of the event that occurred. By type is meant
the name click, mouseover, and
so on. The type property contains the
event type:
elem.addEventListener('click', function(event) {
console.log(event.type); // shows 'click'
});
In the following code, the same handler is attached to two events:
<button id="elem">text</button>
let elem = document.querySelector('#elem');
elem.addEventListener('click', func);
elem.addEventListener('dblclick', func);
function func() {
}
Add a code to the function func so
that when you click on an element, this
element is colored green, and when
double-clicked - red.