[英]How can i input value into object of javascipt?
let inputInf=document.getElementById('inputInf');
let nameStudent=inputInf;
let output= new Student(nameStudent,number);
document.getElementById("btn").onclick=(event)=>{
let xuatTTMH=document.getElementById("outputInfor");
xuatTTMH.innerHTML=output.nameStudent;
}
I thought I can do it this way but the answer is [object HTMLInputElement]
.我以为我可以这样做,但答案是
[object HTMLInputElement]
。 Can you please help me to solve this problem or give me the keyword of this situation?你能帮我解决这个问题或给我这种情况的关键字吗?
Thanks for your help.谢谢你的帮助。
Do you mean the value of nameStudent
is [object HTMLInputElement]
?你的意思是
nameStudent
的值是[object HTMLInputElement]
吗? It's because you didn't get the value from the input field.这是因为您没有从输入字段中获取值。 For the first line, it should be:
对于第一行,它应该是:
let inputInf = document.getElementById('inputInf').value;
You are getting a HTMLInputElement object你得到一个 HTMLInputElement object
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement
There is a 'value' property that you need to check to get the object value from your inputInf var.您需要检查一个“值”属性以从您的 inputInf var 中获取 object 值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.