所以,如果我调用该函数:换行符返回标签的文本价值和附加到每个标签
$("#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