转 html给指定按钮添加回车事件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis" />
<script language="javascript">
function document.onkeydown() {
if(event.keyCode == 13) {
document.getElementById("enter").click();
return false;
}
}
</script>
</head>
<body>
<input type="button" id="enter" value="enter" onclick="alert('enter');"/>
<input type="button" value="123" onclick="alert('123');" />
</body>
</html>
自:http://xiaojunwei1987.blog.163.com/blog/static/929126492009112231250606/