2011-12-01 146 views
0

存在具有兩行的OfficeInfo表格,每個單元格中有兩個單元格。底部第二排的每個單元格都有頂點邊框,這些頂點邊框以奇特的方式將上下兩排分開。如果左下方的單元格爲空,我需要能夠隱藏左邊框,或者如果右下方的單元格是空的,則可以隱藏右邊框。如果沒有內容,則不會只有邊框懸掛在那裏沒有理由..你如何使用jquery做這個?如果單元格爲空,則隱藏單元格頂部邊框

<table class="OfficeInfo" border="0" style="width: 100%" cellspacing="10px" cellpadding="15px"> 
    <tr> 
    <td class="Office1" style="width=40%"> 
    <span class="OfficeName"> 
    Munster Women&#39;s Center<br /> 
    </span> 
    <span class="Address"> 
    8075 North Shadeland Avenue, <br />Indianapolis, IN 46250   
    </span> 
    <span class="Phone"> 
    (321) 223-1232</span><br /> 
    <a class="mapdirectionsLink" href="#">map &#38; directions&#62;</a><br /><br /> 
    <span class="Hours"> 
    MTW: 9:00 AM- 5:00 PM</span> 
    </td> 

    <td class="Office2" style="width:40%"> 
    </td> 
    </tr>          
    <tr>          
    <td class="Office3" style="border-top:1px dotted silver; width:40%;"> 
    </td> 
    <td class="Office4" style="border-top:1px dotted silver; width:40%">       
    </td> 
    </tr> 
</table> 

回答

0

您可以使用jquery:空選擇器來定位空TD並更改邊框CSS屬性。假設前兩名細胞是從來沒有空,你可以做類似

$('table.OfficeInfo td:empty').css('border', '0px'); 
0

你可以試試這個代碼

$('table.OfficeInfo tr:last > td').each(function(){ 
     if($.trim($(this).html()) == ""){ 
      $(this).css('border', '0px') 
     } 
    }); 

希望這有助於

感謝。

相關問題