⊗jqEvtOb 95 of 113 menu

jQuery event object

Now we'll get started with events in jQuery.

When an event is triggered, jQuery generates an event object event, which contains all the information about it. This object is passed to the handler function.

For example, let's find out which tag we click on. Let's take the following HTML code:

<body> <div id="text"></div> <div> <p> <strong><span>click</span></strong> </p> </div> </body>

CSS looks like this:

span, strong, p { display: block; padding: 10px; border: 1px solid black; }

Now we will use the event.target.nodeName property of our event object, which in turn we pass to the click method handler function:

$('body').click(function(event) { $('#text').html('clicked: ' + event.target.nodeName); });

The event object contains many properties and methods.

event
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