0

在字符串中插入换行符的正确语法是什么?我试过 '\n' 但这不起作用...?这是有问题的字符串:

    function layer0(){
  document.getElementById('layerinfo').innerHTML = 'The Wembury Quest ran during June   2012 and was very popular in the parish. Over 400 quest packs were collected from the village school post office and local shops. The Quest was designed to encourage residents to go out into the parish and explore their local landscape. This layer shows the results from the letterboxes. For the letterboxes twelve locations were chosen, spread around the parish. They were picked to take participants to very different types of landscape and views. Some of them were places which they had visited before, and some were off the beaten track and were new to some Questers. All of the locations were found on public rights of way.';
4

4 回答 4

2

\n是在字符串中插入换行符的正确语法。您的问题是您不想在字符串中插入换行符。您想<br>在字符串中插入文本。<br>在字符串中插入文本的正确语法是<br>.

于 2013-05-08T21:51:29.763 回答
1

您希望此中断出现在 HTML 页面中吗?

<br> 

然后

于 2013-05-08T21:50:08.827 回答
1

<br />标签,正如您使用的那样innerHTML

于 2013-05-08T21:50:12.690 回答
0

您可以使用<br>标签换行

于 2013-05-08T21:51:40.253 回答