<input id="txtOrderID" onkeypress="getKey(event)" /> <button onclick="refund()">提交</button> <script src="https://cdn.bootcss.com/jquery/1.8.3/jquery.js"></script> <script> function getKey(event) { if (event.keyCode == 13) { refund(); } } </script>