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>

猜你喜欢

转载自blog.csdn.net/w33365/article/details/23255827