0
我想爲主類別的每個最後一個<tr>
添加一個類。我不想將類名添加到每個<tr>
。我可以在腳本中更改哪些內容?如何向最後一個表格行添加一個類
像這樣:
<table>
<tr>
<th></th>
</tr>
<tr>
<td></td>
</tr>
<tr class="test">
<td></td>
</tr>
<th></th>
<tr>
<td></td>
</tr>
<tr class="test">
<td></td>
</tr>
</table>
<table class="data forum">
<? foreach ($this->mainCategories as $mainCategory): ?>
<tr>
<th><strong><?= $this->escape($mainCategory->fcName) ?></strong></th>
<th> </th>
<th><strong>Topics</strong></th>
<th><strong>Laatste topic</strong></th>
</tr>
<? foreach ($mainCategory->getSubCategories() as $category): ?>
<tr>
<td><a href="<?= $this->url(array('categoryid' => $this->escape($category->getID()), 'controller' => 'forum', 'action' => 'subcategory'), 'default', true) ?>"><?= $this->escape($category->getName()) ?></a></td>
<td><?= $this->escape($category->fcDescription) ?></td>
<? if ($this->escape($category->numTopics) > 0): ?>
<td><?= $this->escape($category->numTopics) ?></td>
<td><?= date_create($this->escape($category->last_topic))->format('d-m-Y H:i') ?></td>
<? else: ?>
<td> </td>
<td> </td>
<? endif ?>
</tr>
<? endforeach ?>
<tr>
<td class="split"></td>
</tr>
<? endforeach ?>
</table>
除非你需要一個特定的結構(刮削或東西),我只想用'建議。 – Ryan
我不認爲CSS僞類可以工作,因爲最後的「mainCategory」'
我想在每個主要類別。因爲我想在每個主要類別之後設計圓角。 – Eric1978
回答
抓住你
$this->mainCategories
變量和測試針對計數器變量的最後一個的count
...更新:
讓我們看一個簡化的版本作爲概念證明:
這將產生以下HTML:最後type`的僞類:
來源
2012-12-16 02:11:20
沒有這個工作。現在這個類只添加到每個子類別tr的最後一個主類別中。 – Eric1978
相關問題