![](/img/trans.png)
[英]intellisense / vs code. how to set up javascript imports correctly?
[英]“value” attribute not showing in javascript code. “ValueOf()” only comes up with the intellisense
为什么我无法访问此javascript代码中的“值”属性。 “ ValueOf()”仅随智能感知一起出现。
function CheckMessage()
{
var contactDetails = [];
var y = document.getElementById('firstName').ValueOf();
}
我想要id为firstName的元素的值,但它没有给我该选项。
这是html:
<form>
First Name:<br><input type="text" id="firstName"><br>
<input type="button" value="Preview Message" onclick="CheckMessage()" >
</form>
这是失败的未捕获的TypeError:对象#没有方法'ValueOf'
javascript上的ValueOf()不存在,带有“ v”。
要访问输入文本,请尝试以下操作:
var y = document.getElementById('firstName').value;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.