JS的onclick不能触发

比如说:
btn.onclick =function (){}这个就不行

btn.onmouseover =function (){}这个就可以运行

反正换成其他事件都可以,就是onclick用不了,也没报错

似乎没啥问题 。我点击生效了


<!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>

<body>
    <button id="btn">888</button>
</body>
<script>
    let btn = document.getElementById("btn");
    btn.onclick = function () {
        alert("99")
    }

</script>

</html>

onclick事件可以生效啊,你这样写吧

 
<!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>
    <style>
 
        div{
            /* margin-top: 3px; */
            /* margin-bottom: 3px; */
            height: 100px;
            width:100px;
            border-radius: 10px;
            background-color: green;
            /* line-height:center; */
            position: absolute; 
            display: block;
        }
        
    </style>
    <script type="text/javascript">

      var count=0;
        function move(){
            alert("你好");
        }
        
    </script>
</head>
<body>
    <button id="btn" onclick="move()">点我弹框</button><br>
 
</body>
</html>

记得把<button>的标签加个type=button试试,即<button type='button'>,或许能好

```