keydown,keypress,keyup,分别是按下,按着没上抬,上抬键盘
<input id="gotoPage" type="button" value="回车按钮" onclick="hc()"/>
<script>
$(document).keydown(function (event) {
if (event.keyCode == 13) {
$("#gotoPage").trigger("click");
}
});
function hc() {
alert("触发成功")
}
if (event.keyCode == 13) {
$("#gotoPage").trigger("click");
}
});
function hc() {
alert("触发成功")
}
</script>