SVG Event.currentTarget Property

Last Updated : 30 Mar, 2022

The SVG Event.currentTarget property identifies the current target for the event, as the event traverses the DOM.

Syntax:

var currentEventTarget = event.currentTarget

Return value: This property returns the object value of the event element.

Example 1: 

html
<!DOCTYPE html>
<html>

<body>
    <svg viewBox="0 0 1000 1000" 
        xmlns="http://www.w3.org/2000/svg">
        
        <circle cx="50" cy="50" r="50" 
            onclick="check(event)" />
            
        <script type="text/javascript">
            function check(event) {
                console.log(event.currentTarget);
            }
        </script>
    </svg>
</body>

</html>

Output:

Example 2: 

html
<!DOCTYPE html>
<html>

<body>
    <svg viewBox="0 0 1000 1000" 
        xmlns="http://www.w3.org/2000/svg">
        
        <text x="50" y="20" font-size="20px" 
            onclick="check(event)">
            GeeksForGeeks
        </text>
        
        <script type="text/javascript">
            function check(event) {
                console.log(event.currentTarget);
            }
        </script>
    </svg>
</body>

</html>

Output:

Comment