0
我有一個有四列的表,最後一列有一個圖像,當我點擊圖像時我想顯示子行。下面是我的代碼:錶行崩潰問題
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<style>
table,th,td {
border: 1px solid black;
}
</style>
<script type="text/javascript">
function showemail(index){
if($("#img" + index).attr("src") == "resources/details_close.png")
{
$("#img" + index).attr("src", "resources/details_open.png");
$("#email" + index).css("display", "none");
}
else
{
$("#img" + index).attr("src", "resources/details_close.png");
$("#email" + index).css("display", "block");
$(".imgClass").each(function(inx){
if(index != inx){
$("#email" + inx).css("display", "none");
$("#img" + inx).attr("src", "resources/details_open.png");
}
});
}
}
</script>
<table style="padding: 20px;" align="center" width="90%" class="display">
<thead>
<tr>
<th width="2%">Id</th>
<th width="10%">First Name</th>
<th width="10%">Last Name</th>
<th width="10%">Email</th>
</tr>
</thead>
<tbody>
<c:forEach var="items" items="${sessionScope.userList}" varStatus="loop">
<tr>
<td>${items.associateId }</td>
<td>${items.firstName }</td>
<td>${items.lastName }</td>
<td>
<img alt="" src="resources/details_open.png"
id = "img${loop.index}" onclick="showemail(${loop.index})"
class="imgClass">
</td>
</tr>
<tr>
<td style="display: none" colspan="4" id="email${loop.index}" align="center">
${items.email}
</td>
</tr>
</c:forEach>
</tbody>
</table>
問題是我不想重新大小的父行的列,但如果我刪除style="display:none"
父列沒有得到重新大小。但如果我保持style="display:none"
那麼它正在調整大小。
你能告訴我我哪裏錯了嗎?
我認爲它需要'表cell'。 – ElChiniNet
啊廢話,OP應該隱藏行,而不是單個單元格。 – epascarello
現在它對我有意義。 +1。 – ElChiniNet