我玩一起在这个片段中,以去除断点(<br/>
),并缠上了我的文字段落:包括超级链接<a> jQuery中。内容
$('.articleText').contents().filter(function() {
return this.nodeType == 3;
}).wrap('<p></p>').end().filter('br').remove();
来源:http://api.jquery.com/contents/
的问题是我的文本包含一个超链接(),这是不包括在本段 - 它只是被排除在外...
这是我的textsnippet:
Lorem Ipsum is simply dummy text of the printing and typesetting industry. <br/><br/>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a <a href="#">galley</a> of type and scrambled it to make a type specimen book.
这是它是如何转化:
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a</p>
<a href="#">galley</a>
<p>of type and scrambled it to make a type specimen book.</p>
,这是应该的:
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a <a href="#">galley</a> of type and scrambled it to make a type specimen book.</p>
这怎么可能......?
还没有运气 - 我的标记中有一个错误,现在正在纠正...... - 我的问题基本上是:“如何将纯文本和链接都包含在同一段中??” - 到目前为止,我的链接站在段落之外... – 2013-04-24 13:01:02