2016-08-15 31 views
1

jqueryを使用してテーブルのコンテンツを変更する必要があります。 私のパットテキストをwoocommerfceチェックアウトページテーブルに変更する必要があります

#post-39 > div > div > div > div.cart_totals > table > tbody > tr:nth-child(3) > th

私は、次のコードを試してみましたが、それは動作しません。

$(document).ready(function(){ 
    $('#post-39 > div > div > div > div.cart_totals > table > tbody > tr:nth-child(3) > th').html('foo'); 
}); 

HTMLは、このコードを試し

$(document).ready(function(){ 
 
    $('table > tbody > tr:nth-child(3) > td').html('foo'); 
 
});
<table cellspacing="0" class="shop_table shop_table_responsive"> 
 
<tbody><tr class="cart-subtotal"> 
 
<th>Subtotal</th> 
 
<td data-title="Subtotal"><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>&nbsp;2,370.00</span></td> 
 
</tr> 
 
<tr class="shipping"> 
 

 
<th>Shipping</th> 
 

 
<td data-title="Shipping"> 
 
</td> 
 
</tr> 
 
<tr class="shipping"> 
 

 
<th>Shipping 2</th> 
 

 
<td data-title="Shipping 2"> 
 
</td> 
 
</tr> 
 
<tr class="order-total"> 
 
<th>Total</th> 
 
<td data-title="Total"><strong><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>&nbsp;2,407.99</span></strong> </td> 
 
</tr> 
 
</tbody></table>

+1

は、私はそれが '何の兄はその目 –

+0

これはwoocommerceチェックアウトページ、私が変更されていないされていない'任意のHTML td'だと思います。彼らはこれをこのように使用しました – uixpider

+0

主に' th'は、テーブルのヘッダー –

答えて

1

IS:

$(document).ready(function(){ 
$('table > tbody > tr:nth-child(3) > th').html('foo'); 

})。

check it

+0

trには1番目と1つのtdがあります。 – uixpider

+0

thに見出しが含まれていて、tdに値が含まれています。値を変更する必要はありません – uixpider

+0

私はHTML部分を私たちに教えてください。 Uが誤ったセレクタを使用した可能性があります –

関連する問題