[英]Onclick and Enter key script
當我按下Enter鍵時,就像單擊按鈕一樣,如何執行相同的操作? 當我按下Enter鍵時,我希望它運行與執行“ onclick”事件時相同的腳本。
<button type="button" value="Login" class="btn green uppercase" onclick="formhash(this.form, this.form.password);">Login</button>
對於您的特定示例:
document.body.addEventListener('keydown', function(e) {
if (e.keyCode == 13) {
formhash(this.form, this.form.password);
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.