1. 程式人生 > >text框中按enter觸發js事件

text框中按enter觸發js事件

原文地址:http://blog.sina.com.cn/s/blog_637766d401010gxn.html


<head>
<script>
function EnterPress(e){ //傳入 event
var e = e || window.event;
if(e.keyCode == 13){
document.getElementByIdx_x_x("txtAdd").focus();
}
}
</script>
</head>
<body>
<input type="text" id="txtName" onkeypress="EnterPress(event)" onkeydown="EnterPress()"

 />
<input type="text" id="txtAdd" />
</body>