Fork me on GitHub

JS获取值&&文本框回车事件

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script type="text/javascript">
        //按钮事件
        function WS() {
            var test = document.getElementById("Text1").value;
            alert(test)
        };
        //回车事件
        function Enter(e) {
            if (e.keyCode == 13) {
                alert('click enter');
            }
        };
    </script>
</head>
<body>
    <input id="Text1" type="text" onkeypress="Enter(event)" />
    <input id="Button1" type="button" value="button" onclick="WS()" />
</body>
</html>

 

posted @ 2018-12-07 20:16  都一样*  阅读(1727)  评论(0编辑  收藏  举报