0
我嘗試使用:如何使用jQuery將輸入文本的值附加到變量中?
$("#userInput").appendTo("gList") //The name of my variable is gList
,但沒有奏效。
我嘗試使用:如何使用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
感謝
請看看文檔。你需要'var gList = $(「#userInput」)。val();' – mplungjan
如果gList是一個數組:'gList.push($(「#userInput」).val());'' – Mat