我玩一起在這個片段中,以去除斷點(<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