Ich habe eine Tabelle, wo ich sowohl eine Zeile auswählen und eine Zeile löschen möchte, aber ich kann nicht herausfinden, wie dies mit JQuery zu tun. Der Code ich habe nur Auswirkungen auf die erste Zeile in der Tabelle. So kann ich die erste Reihe entfernen, aber keine andere. Was ist falsch. Hier ist, was ich versucht:Jquery: Wählen Sie eine Zeile in einer Tabelle und verwenden Sie ihre Daten?
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$("#newCandidatesTable").tablesorter();
var candidateID = $("#candidateID").text();
// Event actions
$("#acceptCandidateButton_" + candidateID).click(function(e) {
$.post("/Admin/AcceptCandidate/", { candidateID: $("#candidateID").text() }, completeAccept());
});
// Functions
function completeAccept() {
showMsgBox($("#candidateName").text() + " er blevet accepteret, som ansøger til stillingen: ...");
$("#tr_" + candidateID).remove();
}
function getFirstNameFromFullName(fullName) {
var nameArray = new Array();
nameArray = fullName.toString().split(" ");
return nameArray[0];
}
});
</script>
<h2>Nye ansøgere</h2>
<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)
{
%>
<tr id="<%= "tr_" + candidate.iAnsogerID %>">
<td><div id="candidateID"><%= candidate.iAnsogerID %></div></td>
<td><div id="candidateName"><%= candidate.vNavn %></div></td>
<td><div id="candidateEmail"><%= candidate.vEmail %></div></td>
<td>
<div id="<%= "acceptCandidateButton_" + candidate.iAnsogerID %>" style="cursor: pointer; border: 1px solid black; width: 150px; text-align: center;">Godkend</div>
</td>
</tr>
<%
} %>
</tbody>
</table>