0

少し問題があるようで、誰かが私を助けてくれるかもしれません。

このコードでやりたいことは、DB からプルされるデータがない場合にテーブルの行/列を非表示にすることです。次のコードでこれをある程度行うことができました:

<div style="border: 1px solid #ccc;">

  <table class="tableizer-table">
    <tr>
      <td class="first-row" colspan="2"># Of Items in Package: <?php echo $_product->getItemsInPackage(); ?></td>
    </tr>
    <tr>
      <td class="second-row">Size Scale</td>
      <td class="second-row">Quantity</td>
    </tr>
    <tr>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_size_1') ?></td>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_quantity_one') ?></td>
    </tr>
    <tr>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_size_2')  ?></td>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_quantity_two') ?></td>
    </tr>
    <tr>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_size_3')  ?></td>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_quantity_three') ?></td>
    </tr>
      <tr>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_size_4')  ?></td>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_quantity_four') ?></td>
    </tr>
    <tr>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_size_5')  ?></td>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_quantity_five') ?></td>
    </tr>
    <tr>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_size_6')  ?></td>
      <td class="cell" style="empty-cells:hide; border-collapse: separate;"><?php echo $_product->getAttributeText('bundle_quantity_six') ?></td>
    </tr>
  </table>
</div>

基本的に、bundle_size_5 & bundle_size_6 (およびその他) - 存在する場合と存在しない場合があり、それらの行/列を非表示にする必要があります。しかし、CSS (ボーダーの例) でスタイルを設定したいと思いますが、それらが隠されていても、予約されたスペースがまだあり、ボーダーがその周りを回っていることに気付きました。

データが存在しない限り、js または jQuery を介してこれらの行/列を完全に非表示にする方法はありますか?

4

1 に答える 1

0

試す、

$(document).ready(function() {   
$('.tableizer-table tr').each(function() {
   var t =  $(this).find('td');
    if ( t.text() === '' ) {
     t.css('borderLeft','0px'); //or border-left
     t.hide();
    }  
  });
 });

デモ

プロパティのマニュアルborderLeftであり、「境界」ではありません。

于 2013-02-20T18:37:26.983 に答える