亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如果 <td> 為空,則無法隱藏 <tr>

如果 <td> 為空,則無法隱藏 <tr>

PHP
當年話下 2023-07-08 15:47:59
<tr>僅當沒有可用數據時我才想隱藏<td>。我嘗試了許多腳本以及 if 條件。但沒有運氣。請幫忙。<table class="table table-striped why-choose-tbl" id="insurance">   <thead>      <tr>         <th scope="col"></th>         <th scope="col">Basic</th>         <th scope="col">Comprehensive</th>      </tr>   </thead>   <tbody>      <tr>        <td>Medical</td>        <td><span><?php the_field('basic_medical') ?></span><i class="fas fa-check"></i></td>        <td><span><?php the_field('comp_medical') ?></span><i class="fas fa-check"></i></td>     </tr>     <tr>        <td>Cancellation</td>        <td><span><?php the_field('basic_cancellation') ?></span><i class="fas fa-check"></i></td>        <td><span><?php the_field('comp_cancellation') ?></span><i class="fas fa-check"></i></td>     </tr>   </tbody></table><script>$('#insurance tr').filter(function() {    return $.trim($(this).text()) === '';}).hide(); // $('#insurance > tbody  > tr').has('td:empty').hide()// $('#insurance > tbody  > tr').each(function () {//    if ($(this).find('td').is(':empty')) {//        $(this).hide();//    }// });</script>我也嘗試如下。但他們都沒有工作。<?php      $basic = the_field('basic_medical');     $comp =the_field('comp_medical');   if (empty($basic) && empty($comp))        {            echo "<td style=/"display:none;/"><i class="fas fa-check"></i><span><?php the_field('basic_medical') ?> </span></td>";            echo "<td style=/"display:none;/"><i class="fas fa-check"></i><span><?php the_field('comp_medical') ?></span></td>";        }?>我可以知道我哪里出了問題嗎?太感謝了。
查看完整描述

1 回答

?
慕的地6264312

TA貢獻1817條經驗 獲得超6個贊

<tr>如果字段為空,則無需打印整個元素。例如,


<?php


$basic_medical = the_field('basic_medical');

$comp_medical = the_field('comp_medical');


?>


<tbody>

    <?php if(!empty($basic_medical) && !empty($comp_medical)): ?>

       <tr>

           <td>Medical</td>

           <td><span><?php the_field('basic_medical')?></span><i class="fas fa-check"></i></td>

           <td><span><?php the_field('comp_medical')?></span><i class="fas fa-check"></i></td>

       </tr>

    <?php endif; ?>


   ...

   ...


    <tr>

       <td>Cancellation</td>

       <td><span><?php the_field('basic_cancellation')?></span><i class="fas fa-check"></i></td>

       <td><span><?php the_field('comp_cancellation')?></span><i class="fas fa-check"></i></td>

    </tr>

</tbody>


查看完整回答
反對 回復 2023-07-08
  • 1 回答
  • 0 關注
  • 108 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號