JavaScript で特定のクラス名の下にある html 要素にアクセスする方法はありますか?
彼女は私がこれまで持っているものです:
部分的:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Student.Models.vwStudent>>" %>
<table>
<tr>
<th>
Student ID
</th>
<th>
Past Due Amount
</th>
<th>
Past Due Days
</th>
</tr>
<% if (Model != null)
foreach (var item in Model) { %>
<tr>
<td class="StudentInv">
<%=Html.TextBox("StudentID",item.StudentID) %>
</td>
<td class="StudentInv">
<%=Html.TextBox("PastDueAmount",item.PastDueAmount) %>
</td>
<td class="StudentInv">
<%=Html.TextBox("PastDueDays",item.PastDueDays) %>
</td>
</tr>
<% } %>
主人:
<div>
<% using(Html.BeginForm("SaveStudentInvoice", "StudentInvoice")) %>
<% { %>
<div>
<% Html.RenderPartial("DisplayStudentInvoiceList"); %>
</div>
<% } %>
<br/>
<input type="button" id="Submit" name="Submit" value="Submit" />
</div>
JavaScript:
$('#Submit').click(function () {
var link = '/StudentInvoice/SaveStudentInvoice';
$.ajax({
type: 'POST',
url: link,
data: { SaveStudent: $(".StudentInv").val()
},
dataType: 'json',
success: function (result) {
alert("Success")
},
error: function (result) {
alert("Failed")
}
});
});
コントローラ:
[HttpPost()]
public ActionResult SaveStudentInvoice(string SaveStudent)
{
/// Parse SaveStudent String and rerform some Action
return View();
}