我有一张桌子,重复的 tbody 完全如下所示:
<tbody>
<tr>
<td class="icons_small" style="color:#fff; vertical-align:middle;"><!--Change color to white if their is attachment--><span class="task_attachment" title="View Attached Items">v</span></td>
<td><span class="active">Task Name</span><br /><span style="vertical-align:middle;" class="icons_small">U</span><span class="contact_name tiny">Contact/Customer</span></td>
<td style="text-align:center;" class="tiny"><span class="date_assigned" title="Date Assigned">13/12/2012</span><br /><div id="progressbar" value="50" title="Progress"></div></td>
<td style="vertical-align:middle;" class="icons_small"><span class="edit_task" title="Edit Task">E</span></td>
<td style="vertical-align:middle;" class="icons_small"><span class="flag_task" title="Flag Task as Important">f</span></td>
<td style="vertical-align:middle;" class="icons_small"><span class="set_reminder" title="Set Reminder">A</span></td>
<td class="tiny" style="color:#333;"><span class="delete_task" title="Delete Task">Delete</span></td>
</tr>
<tr class="attachment" >
<td class="icons_small" style="vertical-align:middle;"><span class="attchement_type" title="Attachment">A</span></td>
<td colspan="6" class="tiny attachment_details">SomeAttachment.pdf</td>
</tr>
</tbody>
使用 jquery,在每个 tbody 中,我隐藏了第二个 tr (class="attachment")。我想显示这个 tr,当我点击上面 tr 的第一个 td 时,它包含 span(class="task_attachment")。但是,我遇到了全有或全无的情况,下面的代码没有给我任何结果,但我认为它更接近我正在寻找的内容。
// Show attached files
<script>
$("tr.attachment").hide();
$("span.task_attachment").click(
function () {
$(this).closest("tr.attachment").show()
});
});
</script>
任何人有任何建议,或看到这有什么问题吗?