1

HTML:

<div id="checkout-review-table-wrapper">
  <table class="data-table" id="checkout-review-table" width="100%">
<colgroup>
<col>
<col width="1">
<col width="1">
<col width="1">
</colgroup>
<thead>
  <tr class="first last">
    <th rowspan="1">Product Name</th>
    <th colspan="1" class="a-center">Price</th>
    <th rowspan="1" class="a-center">Qty</th>
    <th colspan="1" class="a-center">Subtotal</th>
  </tr>
</thead>
<tfoot>
  <tr class="first">
    <td style="" class="a-right" colspan="3"> Subtotal </td>
    <td style="" class="a-right last"><span class="price">AU$891.00</span></td>
  </tr>
  <tr>
    <td style="" class="a-right" colspan="3"> Delivery (Free Shipping - Fixed) </td>
    <td style="" class="a-right last"><span class="price">AU$0.00</span></td>
  </tr>
  <tr class="last">
    <td style="" class="a-right" colspan="3"><strong>Grand Total</strong></td>
    <td style="" class="a-right last"><strong><span class="price">AU$891.00</span></strong></td>
  </tr>
</tfoot>
<tbody>
  <tr class="first odd">
    <td><h3 class="product-name">Portland Polo T</h3>
      <dl class="item-options">
        <dt>Men Tops Size</dt>
        <dd>XL </dd>
      </dl></td>
    <td><span class="cart-price"> <span class="price">AU$99.00</span> </span></td>
    <td class="a-center">3</td>
    <td class="last"><span class="cart-price"> <span class="price">AU$297.00</span> </span></td>
  </tr>
  <tr class="even">
    <td><h3 class="product-name">Graphite Hooded Vest</h3>
      <dl class="item-options">
        <dt>Men Tops Size</dt>
        <dd>XL </dd>
      </dl></td>
    <td><span class="cart-price"> <span class="price">AU$99.00</span> </span></td>
    <td class="a-center">2</td>
    <td class="last"><span class="cart-price"> <span class="price">AU$198.00</span> </span></td>
  </tr>
  <tr class="last odd">
    <td><h3 class="product-name">Radar Low Loose</h3>
      <dl class="item-options">
        <dt>Men Jean Sizing</dt>
        <dd>28/30 </dd>
      </dl></td>
    <td><span class="cart-price"> <span class="price">AU$99.00</span> </span></td>
    <td class="a-center">4</td>
    <td class="last"><span class="cart-price"> <span class="price">AU$396.00</span> </span></td>
  </tr>
</tbody>
  </table>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript">

JavaScript:

var pure = {};
pure = jQuery.noConflict(true);
c=0;
while(c<4)
{
c++;
output='';
pure('#checkout-review-table tbody tr td:nth-child('+c+')').each(function() {
   output += pure(this).text();
});
alert(output);

}

</script>

它一次提供一列的所有数据。我需要一次获取每行的 4 列数据。我的意思是第一行第一列,第一行第二列,第一行第三列,第一行第四列,第二行第一列等等最多12个数据。我无法在上表中进行任何更改更改,也无法添加任何类,因为它是一个自生成的表。我会很感激你的帮助。

4

0 回答 0