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>