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