2013-03-11 33 views
0

我已經作爲的htmlText刪除空行中的htmlText爲textarea的

<p>Here is what some pupils told me about how they prepared for and fared in yesterday's preliminary round.</p> 
<hr /> 

<p>"I will stay calm and try my best. If I do not know a word, I will just have to put something down."</p> 
<p><strong>some text</strong></p> 
<hr /> 


<p>"I am more confident than last year because I have experience. I read the newspaper and I looked through the dictionary for difficult words and tagged them."</p> 
<p><strong>some text</strong></p> 
<hr /> 

我顯示一樣textarea.htmlText。

但textarea顯示上面有太多空行在它們之間。有沒有一種方法可以刪除文本中的換行符?文本正在從服務器端來。

+0

如何試圖替換與空字符串的換行符像這樣:'的htmlText = htmlText.replace(?/ \ r \ N/G, 「」);' – 2013-03-11 09:00:58

+0

這是要除去每一次換行,我至少需要一個換行符,但是如果有更多的換行符需要刪除它們。 – sharmacal 2013-03-11 10:09:44

+1

好吧,然後將上面的正則表達式改爲這個'/ \ r?\ n {2,}/g'。這將只消除兩個或更多的模式發生。 – 2013-03-11 10:41:57

回答

0

在CSS中設置p標籤。
實施例:

p{ 
     line-height:0.5; 
    }