CurrentTarget event properties

currentTarget case attribute The event object

Definitions and usages

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

This property is useful during the capture and foaming phases because it is different from the target property in both nodes.

Grammar

event .currentTarget


Here's an example of which element's listener triggered the event:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在线教程(w3cschool.cn)</title>
<script>
function myFunction(e){
alert(e.currentTarget);
}
</script>
</head>
<body onclick="myFunction(event)">

<p>点击这个段落。一个警告框将警报eventlistener触发事件的元素。</p>
<p><strong>注意:</strong> currentTarget属性并不一定返回点击的元素,eventlistener触发事件的元素。</p>

</body>
</html>

Try it out . . .


currentTarget case attribute The event object