[英]How can I append the value of an input text into a variable with jQuery?
I tried using: 我尝试使用:
$("#userInput").appendTo("gList") //The name of my variable is gList
but it didn't work. 但这没用。
As i understand this gList
this is an array so you have to do next 据我了解这gList
这是一个数组,所以你必须下一步
var gList = [];
// ... do some job
var inputValue = $("#userInput").val(); //console.log(inputValue)
gList.push(inputValue); // console.log(gList)
If gList
is a string you can concatenate it gList = gList + inputValue
如果gList
是字符串,则可以将其串联起来gList = gList + inputValue
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.