javascript回车提交表单

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>javascript回车提交表单</title>
</head>
<body>
<input type="text" id="enter"/>
<script>

    window.onload=function(){
    var enter=document.getElementById("enter");
        enter.onkeyup=function(e){
            var e= e||window.event;
            var keycode= e.keyCode|| e.which|| e.charCode;
            if(keycode==13){
                alert("提交表单");
            }
        }
    }

</script>
</body>
</html>

你可能感兴趣的:(javascript回车提交表单)