JavaScript如何获取当前点击对象节点

时间:2024-10-21 07:19:49

/*传入参数this即可获取当前点击的对象*/

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>获取当前点击对象</title>
    <link rel="stylesheet" href="">
</head>
<body>
    /*传入参数this即可获取当前点击的对象*/
    <span   οnclick="capture(this)">点我</span>
</body>
<script>
    function capture(data) {
        ();
        alert();
    }
</script>
</html>