1

WP eCommerce のカスタム メタ フィールドにイメージ タグを追加する必要がありますが、追加するとテキストとして表示されます。したがって、Jquery を使用して < > ブラケットを見つけて置き換え、代わりにタグとしてレンダリングされるようにします。

ここに私のソースコードがあります:

<div class="custom_meta">
<strong>CODE: </strong>JL16<br>
<strong>Colour: </strong>&lt;img src="http://localhost:81/live_products/shop/wp-content/uploads/blue.gif" /&gt;<br>
<strong>COLOURS: </strong>BLACK, WHITE, GREY, CORAL, BLUE<br>
<strong>FABRIC: </strong>LYCRA<br>
</div>

jQueryで動作するはずだと思う方法は次のとおりです。

jQuery(document).ready(function(){

    // Remove "" from meta image
    jQuery(".custom_meta").replace(/&lt;/g, '<');
    jQuery(".custom_meta").replace(/&gt;/g, '>');

});

&lt;これはto < とto >を置き換える正しい方法&gt;でしょうか?

ありがとうございました。

4

1 に答える 1

1

これでできるはず

jQuery(".product_description").html(function(i, currenthtml){
   return currenthtml.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
});

詳細については、ドキュメントを参照してください。.html()

于 2012-11-12T13:42:03.470 に答える