currentTarget Event Property - Javascript DOM

Javascript examples for DOM:Event

Description

The currentTarget event property returns the element who triggered the event.

Return Value

A reference to the object whose event listeners triggered the event

The following code shows how to get where is the event from.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body onclick="myFunction(event)">

<p>Click on a paragraph. </p>

<script>
function myFunction(event) {//from w w  w . j  a v a  2  s.  c o m
    console.log(event.currentTarget.nodeName);
}
</script>

</body>
</html>

Related Tutorials