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>