currentTargetEvent Property

事件对象参考手册Event Object

Definition and Usage

The currentTarget event property returns the node whose listener triggered the event, that is, the element, document, or window currently handling the event.

During the capturing and bubbling phases, this property is very useful because in these two phases, it differs from the target property.

Syntax

event.currentTarget


Example

Example

The following example can get which element's listener triggered the event:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function myFunction(e){
    alert(e.currentTarget);
}
</script>
</head>
<body onclick="myFunction(event)">
    
<p>Click this paragraph. An alert box will alert the element whose eventlistener triggered the event.</p>
<p><strong>Note:</strong> The currentTarget property does not necessarily return the clicked element, but the element whose eventlistener triggered the event.</p>

</body>
</html>

Try it yourself »


事件对象参考手册Event Object Other Extensions