按下enter触发事件

时间:2019-04-28 11:12:43   收藏:0   阅读:84

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <input placeholder="输入一些文本" type="text">
        <script>
            var inputText=document.querySelector("input");
            inputText.addEventListener("keyup",function(e){
                if(e.keyCode==13){
                    alert(1)
                }
            })
        </script>
    </body>
</html>

原文:https://www.cnblogs.com/zimengxiyu/p/10782398.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!