html 求按Enter后,自动触发指定button的click事件

来源:百度知道 编辑:UC知道 时间:2024/06/22 21:50:18
<!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() {
var e=event.srcelement;
if(event.keycode==13) {
document.
document.getelementbyid("enter").click();
return false;
}
}
</script>

</head>

<body>
<input type="button" id="enter" value="enter" onclick="alert('enter');&quo

<!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=&q