2011-01-16 6 views

答えて

1

あなたがHTMLの文字列にjQueryの操作を行いたい場合は、最初にそれを変換するために、jQueryのを使用します。

var newContent = $(format(html)); // use the results of `format(html)` to make a jQuery selection 
$(tag).append(newContent.text()); // use the jQuery text method to get the text value of newContent 

See the API for an explanation of how this works

3

$('<span class="opt">some text</span>').text()仕事をするか、あなたのケースでする必要があります、テキスト「<span>...</span>」を取るjQueryオブジェクトに変換し、タグを残し、テキストを抽出します

$(tag).append($(format(html)).text()); 
+0

そこに 'text'の後ろに'() 'がありません。これでjQueryソースコードの一部を追加します! – lonesomeday

+0

イェップ、ちょうど実現し、それを修正しました:-) –

0
$(tag).append($(format(html)).text());