为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我得不到value值?

为什么我得不到value值?

19990000 2017-10-04 23:43:02
<!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">            <button type="submit">验证</button>        </p>        <p>必填,长度为4~16个字符</p>    </form> </body> <script>    var names = document.getElementById("names").value;    var namesValue = names.value;    console.log(namesValue); </script> </html>
查看完整描述

1 回答

?
Kiwis

TA贡献39条经验 获得超13个赞

第一,输入表单没有值。第二,document.getElementById().value的时候已经获取value。value下没有value属性

查看完整回答
1 反对 回复 2017-10-05
  • 19990000
    19990000
    输入值之后,在表单当中也不显示value
  • 1 回答
  • 0 关注
  • 1180 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信