HTML Display line breaks within textarea

后端 未结 3 892
逝去的感伤
逝去的感伤 2020-12-16 09:57

I have asked this question now several ways, but still have not gotten an answer.

When you capture asci text in a textarea that includes line breaks, it seems to ins

3条回答
  •  天命终不由人
    2020-12-16 10:50

    If you are using javascript you can use the textarea element value Property.

    var tb = document.getElementById("tb");
    
    var newLine = "\r\n";
    
    var text = "Output: " + newLine + "-------------------" + 
                            newLine + "line 1:	" + 
                            newLine + "line 2:	";
    
    tb.value = text;
    //console.log(text);

    Run it on JSFiddle

提交回复
热议问题