I know this has to be be doable, does anyone know how and if you can do it?
4 Answers
or you can do it this way:
var myVar = 'sup fresh our turn baby!';
var myTextArea = document.getElementById('myArea');
myTextArea.innerHTML += myVar;
1 Comment
Guyver
woot woot? then someone might call me a nerd :/
Something like this should work:
var textArea = document.getElementById("mytextarea"); // assuming there is a textarea with id = mytextarea
var textToAppend = document.createTextNode("Hello, World!");
textArea.appendChild(textToAppend);
EDIT: or, as Pointy suggested, the last two lines can be replaced by:
textArea.value += "Hello, World!";
1 Comment
Pointy
Why not just
textArea.value += textToAppend; ??function appendText(str) {
var obj=document.getElementById("myTextArea")
var txt=document.createTextNode("append this text")
obj.appendChild(txt)
}
1 Comment
Pointy
Same question to you as I asked @GreginYEG: why not just append to the "value" attribute of the
<textarea> ?? Why go to the expense of creating a node (slow in IE)?