2016-03-01 66 views
1

我有这样的代码:Laravel标签不可见

<div class="container col-md-6 col-md-offset-3"> 
     <div class="well well bs-component"> 
      <table class="table"> 
       <thead> 
        <tr> 
         <th>Logo</th> 
         <th>Bedrijfsnaam</th> 
         <th>Plaats</th> 
        </tr> 
       </thead> 
       <tbody> 
       @foreach($companies as $company) 
        <a href="/bedrijf/{!! $company->CompanyId !!}"> 
         <tr> 
           <td><img class="img-circle-company" src="{!! $company->Logo != null ? '/files/images/companylogos/'.$company->Logo : '/files/images/companylogos/default.png'!!}"/></td> 
           <td>{{ $company->CompanyName }}</td> 
           <td>{{ $company->City }}</td> 
         </tr> 
        </a> 
       @endforeach 
       </tbody> 
      </table> 
     </div> 

但标签不工作这是为什么?在我的网页源代码,它看起来是这样的:

enter image description here

+2

你在包装标签,这是不合法的HTML那么您的浏览器可能会剥离了这一点,一个TR http://stackoverflow.com/questions/10245279/wrapping-html-table-rows-in -a标签 – markdwhite

回答

1

不幸的是包裹在一个锚<tr>元素是无效的HTML。有些浏览器可能不会眨眼睛,但大部分浏览器会删除有问题的元素。如果您想继续使用表格,另一个选项是在每个<td>元素内添加锚点。

<div class="container col-md-6 col-md-offset-3"> 
    <div class="well well bs-component"> 
     <table class="table"> 
      <thead> 
       <tr> 
        <th>Logo</th> 
        <th>Bedrijfsnaam</th> 
        <th>Plaats</th> 
       </tr> 
      </thead> 
      <tbody> 
      @foreach($companies as $company) 
       <tr> 
        <td> 
         <a href="/bedrijf/{!! $company->CompanyId !!}">       
          <img class="img-circle-company" src="{!! $company->Logo != null ? '/files/images/companylogos/'.$company->Logo : '/files/images/companylogos/default.png'!!}"/> 
         </a> 
        </td> 
        <td><a href="/bedrijf/{!! $company->CompanyId !!}">{{ $company->CompanyName }}</td> 
        <td><a href="/bedrijf/{!! $company->CompanyId !!}">{{ $company->City }}</a></td> 
       </tr> 
      @endforeach 
      </tbody> 
     </table> 
    </div> 
</div>