实现代码如下:
<script type="text/javascript"> window.onkeydown = function () { var EventUtil = {}; EventUtil.getEvent = function () { if (window.event) { return window.event; } else { return EventUtil.getEvent.caller.arguments[0]; } } //绑定你的id为submit的按钮事件 var button = document.getElementById("submit"); if (EventUtil.getEvent().keyCode == 13) { button.click(); //取消事件的默认操作 event.returnValue = false; } }</script>
转载于:https://www.cnblogs.com/h123/p/4864757.html