JQuery を機能させることができないようです。すべてのモデルをテーブル形式で表示するループを持つビューを添付しました。各モデルの横にチェックボックスがあります。テーブル ヘッドには、checkAll としてチェックボックス アイテム名/ID もあります。JQuery スクリプトを参照し、関数を追加しました。checkAll チェックボックスをクリックしても何も起こりません。私はJQueryに非常に慣れていないので、これを解決できませんか?
@model IEnumerable<MVC_Example2___ADO.Models.Employees>
@{
ViewBag.Title = "Delete";
}
<script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript" >
</script>
<script type="text/javascript">
$(function () {
$("#checkAll").click(function () {
$("input[name='EmployeeIDToDelete']").click(function () {
if ($("input[name='EmployeeIDToDelete']").length == $("input[name='EmployeeIDToDelete']:checked").length) {
$("#checkAll").attr("checked", "checked");
}
else {
$("#checkAll").removeAttr("checked");
}
})
})
})
</script>
<html>
<body>
@using (Html.BeginForm())
{
<table align="center" border="1" style="border:ridge;">
<thead>
<tr>
<td><input type="checkbox" id="checkAll" name="checkAll" /> </td>
<td>Photo</td>
<td>Name</td>
<td>Gender</td>
</tr>
</thead>
<tbody>
@Html.EditorForModel()
</tbody>
</table>
<input type="submit" name="submit" value="Delete Entries" />
}
</body>
</html>