Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add text to text area using javascript

How can I add custom text to already written text in textarea using javascript??Thanks...

like image 701
halocursed Avatar asked Sep 16 '09 00:09

halocursed


1 Answers

function addText(elId,text) {
    document.getElementById(elId).value += text;
}

or:

function addText(elId,text) {
    var obj = document.getElementById(elId);
    var txt = document.createTextNode(text);
    obj.appendChild(txt);
}
like image 174
karim79 Avatar answered Nov 15 '22 22:11

karim79