Latest web development tutorials

target event property

Event Object Reference Event objects

Definition and Usage

target event property returns the target node event (trigger node of the event), such as generating elements of the event, or the document window.

grammar

event .target

Examples

Examples

The following examples can be obtained trigger elements of the event:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function myFunction(e){
    alert(e.target);
}
</script>
</head>
<body onclick="myFunction(event)">

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

</body>
</html>

try it"


Event Object Reference Event objects