このhtmlで:
<blockquote class="stat">
There are ’paper cups‘ in there.
</blockquote>
私はこのビットのjQueryを使用しています:
function replaceEntity(element, entity, replacement) {
$(element).each(function() {
$(this).html(function(i, html) {
return html.replace('‘', '<span class="rsquo">’</span>').replace('’', '<span class="lsquo">‘</span>');
});
});
}
これを生成する:
<blockquote class="stat">
There are <span class="rsquo"><span class="lsquo">‘</span></span>paper cups<span class="lsquo"><span class="rsquo">’</span></span> in there.
</blockquote>
しかし、私はこれが欲しい:
<blockquote class="stat">
There are <span class="rsquo">’</span>paper cups<span class="lsquo">‘</span> in there.
</blockquote>
どうやって
- ネストなしで両方のエンティティをスキャンするための検索を取得しますか?
- htmlエンティティをUTF-8に相当するものに置き換えるjQueryを停止しますか?
編集
ネスト エラーは、別の開発者ドキュメントの別のスニペットにリンクされていました。この質問は最後に削除します。