前端js移入[onmouseover事件]div改变颜色event.target

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box {
      
      
        width: 100px;
        height: 100px;
        background: skyblue;
    }
</style>

<body>
    <div>
        <div>
            <h1>onmouseover事件</h1><br>
            <div class="box" onmousemove="move(event)"></div>
        </div>
    </div>
</body>
<script>
    function move(event) {
      
      
        event.target.style.backgroundColor = "#ccc";
    }
</script>

</html>

猜你喜欢

转载自blog.csdn.net/m0_49714202/article/details/126321081