0

スパンクラスが「price-red」の div「price」に грн テキストがあります

    <div class="price">

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
    <td width="190"><span class="price-text">Цена для вас:</span></td>
    <td></td>
    <td></td>
</tr>
<tr><td colspan="3" height="10"></td></tr>
<tr>
    <td><nobr><span class="price-red"><b>299 грн.</b></span></nobr></td>
    <td></td>
    <td></td>
</tr>
</table>
</div>

CSS

.price-red{
font-family: Arial, Helvetica, sans-serif;
font-size: 60px;
text-transform: none;

}

jqueryで見つけて、「грн」のフォントを60pxから40pxに変更する必要があるので、これを試しました:

<script>
$(document).ready(function(){
  $('span.price-red:contains("грн")').css('font-size', '40px');
});
</script>

テキスト299 ポンド。次のようにphpによって生成されます。

<td><?php if (!empty($special)){ ?><span class="price-red">Sale!</span><?php }else{ ?><nobr><span class="price-red"><b><?php echo $price; ?></b></span></nobr><?php } ?></td>
    <td><?php if (!empty($special)){ ?><span class="price-red"><b><?php echo $special; ?></b></span><?php } ?></td>
    <td></td>
</tr>

答え

   $(document).ready(function(){
$('span.price-red:contains("грн")').html(function () {
    return this.innerHTML.replace("грн", "<span style='font-size:40px'>грн</span>")
});
});
4

3 に答える 3

2

rph のみを変更したい場合は、html() でこれを行い、rph をスパンでラップします。

$('span.price-red:contains("грн")').html(function () {
    return this.innerHTML.replace("грн", "<span style='background:blue;font-size:40px;'>грн</span>")
});

デモ

于 2013-10-14T12:33:02.383 に答える
0
$(document).ready(function(){
  $('.price span.price-red:contains("грн")').css('font-size', '40px');
});

参照を含むセレクター

于 2013-10-14T12:24:43.923 に答える