I am using map()
to collect the text-box values into an array, and then printing the values in a paragraph successfully.
$("p")
.append($("input").map(function() {
return $(this).val();
})
.get()
.join(", "));
However I want to store the concatenated values in a variable before showing it on the screen, so that I can re-use the value later. How can I store this value without appending it to the <p>
tag?
Never mind. For anybody with a similar need, I did this:
var x = $("input").map(function() {
return $(this).val();
})
.get().join(", ");
$("p").append(x);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.