<!DOCTYPE?html>
<html>
<head>
???<meta?charset="UTF-8">
???<title>表單驗證</title>
???<style>
???????.title{
???????????font-weight:?bold;
???????????font-size:18px;
???????}
???????.names{
???????????width:358px;
???????????height:42px;
???????????margin-left:38px;
???????????-webkit-border-radius:5px;
???????????-moz-border-radius:5px;
???????????border-radius:5px;
???????}
???????.btn{
???????????width:78px;
???????????height:42px;
???????????margin-left:15px;
???????????background:?rgb(46,122,184);
???????????color:?#fff;
???????????font-size:18px;
???????????font-weight:?bold;
???????????outline:?none;
???????????border:0;
???????????border-radius:?5px;
???????}
???????.prompt{
???????????margin-left:78px;
???????????font-size:16px;
???????????color:?#ccc;
???????}
???</style>
</head>
<body>
???<form?action="#">
???????<p>
???????????<label?for="names">名稱</label>
???????????<input?type="text"?id="names"?name="user_name"?value="">
???????????<button?type="submit">驗證</button>
???????</p>
???????<p>必填,長度為4~16個字符</p>
???</form>
</body>
<script>
???var?names=document.getElementById("names").value;
???console.log(names);
</script>
</html>
為什么我這個在input中輸入值的時候,console都不顯示值?
19990000
2017-10-05 11:51:22