javascript 带有 .value 的对象 HTMLInputElement 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24476767/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
object HTMLInputElement error with .value
提问by user3722860
I have a problem with returning "[object HTMLInputElement]", this is my code:
HTML:<input type="text" id="numb7">
JavaScript:var numb7 = document.getElementById("numb7").value;
When I alert numb7 it returns:
[object HTMLInputElement]
Can anyone help me?
我在返回“[object HTMLInputElement]”时遇到问题,这是我的代码:
HTML:<input type="text" id="numb7">
JavaScript:var numb7 = document.getElementById("numb7").value;
当我警告 numb7 时它返回:
[object HTMLInputElement]
谁能帮帮我?
For the full code: Full Code
完整代码:完整代码
回答by Nisse Engstr?m
Perhaps it's an old MSIE compatibility feature where all id
and name
attributes are added to the global object. Try giving your variable (or id
) a different name.
也许这是一个旧的 MSIE 兼容性功能,其中所有id
和name
属性都添加到全局对象中。尝试给您的变量(或id
)一个不同的名称。