琴& 2019-01-21 19:29 采纳率: 33.3%
浏览 430
已采纳

为啥这个事件执行不了???

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

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

<body>
    <div class="a"></div>
    <div class="a"></div>
    <div class="a"></div>
    <div class="a"></div>
    <div class="a"></div>
    <div class="a"></div>

    <script>
        var a = document.getElementsByClassName('a');
        var i = 0;

        for (i = 0; i < a.length; i++) {
            a[i].onmouseover = function () {

                a[i].style.height = '200px';
            };
        }
    </script>
</body>

</html>
  • 写回答

2条回答 默认 最新

  • 天际的海浪 2019-01-21 20:01
    关注

    this.style.height = '200px';

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?