将换行符和字符串一起存储在变量中

store newline character with string in a variable

本文关键字:变量 存储 一起 换行符 字符串      更新时间:2023-09-26

我已经将这个字符串存储在xml中。。。用咏叹调读取,然后用下面的代码打印

 $("#"+obj.id +" .frontText").html("<h2>"+fTitle[origImg]+"</h2>"+"<br/>"+backText[origImg]);

我想在此背景文本中打印换行符。怎么做我试过了,但是不起作用。

代码::

   <backTxt>HarbourFront Tower One is an 18-storey office buillding which houses many blue-chip multinational corporations.                            
        It was developed as part of the HarbourFront Precinct rejuvenation project to meet the growing demand of businesses relocating to the fringe of the CBD. 
The development is located near supporting amenities and public transport.
</backTxt>   

我想这样打印:

HarbourFront Tower One是一栋18层的办公楼,里面住着许多蓝筹跨国公司
它是作为海滨区复兴项目的一部分开发的,以满足搬迁到CBD边缘的企业日益增长的需求。该开发项目位于配套设施附近以及公共交通。

您正在输出HTML代码,HTML使用<br>表示换行符,因此这就是您需要输出的内容。