所以,如果我調用該函數:換行符返回標籤的文本價值和附加到每個標籤
$("#item").text()
這個HTML代碼:
<div id="item">
<pre><span class="cm-tag"><html></span></pre><pre><span class="cm-tab"> </span>asdf</pre><pre><span class="cm-tag"></html></span></pre>
</div>
返回:
'<html> asdf</html>'
我想要它回來:
'<html>
asdf
</html>'
基本上,我需要在每個<pre>
標記後面添加一個新行......我該怎麼做?
就像我不希望它們通過'\ n's'連接在一起,我希望它們被加入,就好像你在按壓輸入javascript變量一樣......如果這樣做有道理 – maxhud
這將返回:「 asdf」 – maxhud
@maxhud '\ n'被稱爲[newline](http://en.wikipedia.org/wiki/Newline#In_programming_languages)字符,可用於許多語言ges包含c,javascript,python和其他許多表達式,就像「你按下回車鍵」一樣。編輯我的答案與工作解決方案的jsfiddle的鏈接。 – Trevor