⊗jsPmOEET 417 of 504 menu

Event type in the Event object in JavaScript

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.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline