繁体   English   中英

如何使用jQuery将输入文本的值附加到变量中?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM