Javascript Line Break Textarea

前端 未结 5 1928
忘掉有多难
忘掉有多难 2020-12-18 22:11

I have a text area that I want to pre-populate with some specific text that includes line breaks. I\'m populating the area onLoad but I can\'t get the line breaks to work c

5条回答
  •  忘掉有多难
    2020-12-18 23:00

    As stated multiple times, you need the \n character.

    see here: http://jsfiddle.net/XbALv/

    document.getElementById("blah").value = 
    "This" + "\n" +
    "is some" + "\n" +
    "text" + "\n";
    

提交回复
热议问题