Reputation: 1968
I'd like to append a string to a text area, followed by a new line.
My research shows that Here's what I've tried thus far, but have not had any luck with:
function putStr(str){
document.getElementById('output').value += str +\n;
}
function putStr(str){
document.getElementById('output').value += str \n;
}
function putStr(str){
document.getElementById('output').value += str;
document.getElementById('output').value += \n;
}
Thanks!
Upvotes: 0
Views: 49
Reputation: 35276
put your new line in a string, since it's not a variable.
function putStr(str){
document.getElementById('output').value += str + '\n';
}
Upvotes: 1
Reputation: 894
Give this a go with the quotes
function putStr(str){
document.getElementById('output').value += str +"\n";
}
JS Fiddle: http://jsfiddle.net/DeanWhitehouse/xk4W3/
Upvotes: 1