offline version v3


⊗jsPmDmDEH 345 of 502 menu

Handlers for different events in JavaScript

In addition to clicking on an element, there are other events. For example, using the dblclick event, you can catch a double click on an element, using the mouseover event - hovering over the element, and using the mouseout event - leaving the cursor from the element.

At the same time, handlers of various types of events can be attached to one element. Let's, for example, bind a cursor hover response and a leave response to the same element:

button.addEventListener('mouseover', function() { console.log('1'); }); button.addEventListener('mouseout', function() { console.log('2'); });

Given a button. By double-clicking on it, display some message.

Given a button. Display a message by hovering over it.

Given a button. When the cursor leaves it, display some message.

Given a button. Display one message when you hover over it, and another message when you leave it.

enru