テーブル内のテキストを画像に置き換えたいと考えています。テキストのバリエーションは、強、中、弱の 3 つです。これは、コーヒー製品の強度を優先するためです。テキストに強いと書かれている場合は、「strong.png」などに置き換えたいと思います。ここまで来ましたが、アイデアが詰まっています。以下は機能しません。
これまでの私のコード:
$().ready(function () {
$('.data-table tr .data').each(function () {
string = $(this).text('Strong');
$(this).html('<img src="strong.png" alt="' + string + '" />');
});
});
</script>
テーブルのマークアップは次のとおりです。
<table class="data-table" id="product-attribute-specs-table">
<colgroup><col width="25%">
<col>
</colgroup><tbody>
<tr class="even">
<th class="label">Coffee Strength</th>
<td class="data last">Strong</td>
</tr>
</tbody>
</table>
どんな助けでも大歓迎です。