如何在 JavaScript 函数(jQuery)中访问“StudentID”值。
HTML:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Student.Models.vwStudent>>" %>
<div class="divClass" id="divID">
<table class="tableClass" id="tableID">
<% foreach (var item in Model) { %>
<tr class="trClass" id="trID">
<td class="tdClass">
<%= Html.TextBox("StudentID") %>
</td>
<td class="tdClass">
<%= Html.Encode(item.StudentName) %>
</td>
</tr>
<% } %>
</table>
</div>
查询:
$('#ShowStudentID').click(function () {
$(".tdClass").each(function () {
alert($('.tdClass').children().val());
// How do I access StudentID and StudentName here?
});
});