JS按钮点击事件实现弹窗(popup)

click.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>click</title>
    <script>
        function buttonClick(){
            
     
            window.confirm("你点击了按钮哦");
        }
    </script>

    <script>
        window.onload = function(){
            
     
            var btn = document.getElementById("button1");
            btn.addEventListener(click,function() {
            
     alert(你点击了按钮哦!)},false);
        }
    </script>
</head>
<body>

<input  id="button" type="button" value="点击" onclick="buttonClick();">
<input  id="button1" type="button" value="点击1" >
<input  id="button2" type="button" value="点击2" >
<script>
    var btn = document.getElementById("button2");
    btn.onclick =function(){
            
     
        alert("你点击了按钮哦2!");
    }
</script>

</body>
</html>
经验分享 程序员 微信小程序 职场和发展