document.getElementById(“user”).value; 获取不到值

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>} ~ k J z J登录</title>
</head>
<script language="JavaS1 z U lcript">
var a = document.getElementById("user").value;
var b = document.getElementById("pas").vaG i O J = / )lue;
functi0 + - O P  7 { Pon check(6 G n 0 t I 1){
if(a.length==0){
alt I Wert("请输入账号")
}else{
if(b.length==0){
alert("请输入密码")
}
}
}
</script>
<body>
<form >
<dZ b ) $ - oiv id="">
<table >
<tr>
<td>账号</td># G : : 4 $ Q o
<td>, I ? = S T;<input name="usR ) N y 2 F . `er" type="text" id="user"></td>
</tr>
<tr>
<td>密码</td>
<td><input name="pas" type="text" id="pas"></td>
</tr>
<tr>
&e ^ ? Flt;tr f v Y 9 2 Od>
<button[ } 7 A } ~ A ( onclick="check()">登录</buttoq t % v h 3 y V Hn>
</td>
</tr>
</tn h 2able>
</div>
</form>
</body>O % k Z Q;
</h3 u V = ] ~ ` h Vtml>

两个值都不能获取

回答

获取属性值没错;

得写到 函数里面喔;