I'm trying to output the values of multiple input-fields into a single div. But I simply can't get it to work. It will only output one of the input-fields into the div at a time.
This is my jquery:
var $output = $('#output-content-here');
$('input').keypress( function() {
$($output).text(this.value);
});
I have made a jsiddle to show you what i mean: http://jsfiddle.net/A7UbK/1/
Thanks.
Try the following code using .map()
var $output = $('#output-content-here');
$('input').keyup(function () {
$output.html(function () {
return $('input').map(function () {
return this.value
}).get();
})
});
Demo
Note : $output already contains jQuery object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With