2011-12-01 120 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') 
     } 
    }); 

希望这有助于

感谢。

相关问题