How to force a line break on a Javascript concatenated string?

后端 未结 4 1077
傲寒
傲寒 2020-12-10 00:25

I\'m sending variables to a text box as a concatenated string so I can include multiple variables in on getElementById call.

I need to specify a line break

4条回答
  •  时光说笑
    2020-12-10 00:55

    You need to use \n inside quotes.

    document.getElementById("address_box").value = (title + "\n" + address + "\n" + address2 + "\n" + address3 + "\n" + address4)

    \n is called a EOL or line-break, \n is a common EOL marker and is commonly refereed to as LF or line-feed, it is a special ASCII character

提交回复
热议问题