스크립트를 선택하여 강조 표시된 행을 강조 표시하고 행이 선택/강조 표시 될 때 다른 행이 선택/강조 표시되도록하고 싶습니다. 행이 선택됩니다. 어떻게해야합니까?Jquery : 클릭시 테이블 행 강조 표시/강조 표시
$(".candidateNameTD").click(function() {
$(this).parents("tr").toggleClass("diffColor", this.clicked);
});
HTML 테이블
<table id="newCandidatesTable">
<thead>
<tr>
<th style="cursor: pointer;">ID</th>
<th style="cursor: pointer;">Navn</th>
<th style="cursor: pointer;">Email</th>
<th></th>
</tr>
</thead>
<tbody>
<% foreach (var candidate in Model.Ansogninger)
{
%>
<tr id="<%= candidate.AnsogerID %>" class="newCandidatesTableTr">
<td><div id="candidateID"><%= candidate.AnsogerID %></div></td>
<td><div id="<%= "candidateName_" + candidate.AnsogerID %>" class="candidateNameTD"><%= candidate.Navn %></div></td>
<td><div id="candidateEmail"><%= candidate.Email %></div></td>
<td>
<div id="<%= "acceptCandidateButton_" + candidate.AnsogerID %>" class="acceptb" style="cursor: pointer; border: 1px solid black; width: 150px; text-align: center;">Godkend</div>
</td>
</tr>
<%
} %>
</tbody>
</table>
이렇게하면 클릭 한 행만 선택 취소됩니다. –
덕분에, 나는 당신의 아이디어를 사용했습니다 ... 그것은 나를 위해 가장 논리적이었습니다. – Poku
btw 중첩 된 테이블이 있으면 모든 tr과 일치합니다. 가장 가까운 쪽이 더 낫다. – redsquare