Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.innerHTML doesn't work properly (I guess)

I use .innerHTML to add text in textarea. But If I starting edit text in textarea by myself script stops working.

Here it is:

(function($){
addPort = function(name) {
    switch(name) {
    case 'name1':
        var code = "text1"; 
        break
    case 'name2':
        var code = "text2";
        break
    case 'name3':
        var code = "text3";
        break
    default:
        break
    }
    document.getElementById("codeArea").innerHTML += code;
}; })(jQuery);

Don't pay attention on jQuery. Some other function use it.

Here's the textarea:

<textarea id="codeArea" name="codeAreaPost"></textarea>

Thanks.

like image 247
Timofey Trofimov Avatar asked Feb 20 '23 12:02

Timofey Trofimov


1 Answers

its just replace innerHTML by value property

document.getElementById("codeArea").value

not innerHTML

like image 98
Pranay Rana Avatar answered Mar 03 '23 18:03

Pranay Rana