event.currentTarget Property - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:event.currentTarget

jQuery event.currentTarget Property

Description

The event.currentTarget property is the current DOM element in the event bubbling phase, and is typically equal to this.

Syntax

Parameter Description
event Required. The event parameter comes from the event binding function

The following code shows that event.currentTarget is typically equal to this:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("h1, h2, p").click(function(event){
        console.log(event.currentTarget === this);
    });/*from w w w .ja v  a  2s .  c om*/
});
</script>
</head>
<body>

<h1>Heading 1 click me</h1>
<h2>Heading 2 click me</h2>

</body>
</html>

Related Tutorials