我有下面的代碼,它有按鈕和click
它應該顯示hidden
窗體。但它不,爲什麼?爲什麼隱藏窗體不顯示?
@model EmployeesTest.Models.EmployeeVM
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
<input type="submit" name="name" value="New Entry" id="new"/>
@using (Html.BeginForm()) {
<div id="frm" style="visibility:hidden">
<table>
<thead>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
<tr>
<td>@Html.LabelFor(x=>x.emp.FirstName)</td>
<td>@Html.TextBoxFor(x=>x.emp.FirstName)</td>
<td>@Html.ValidationMessageFor(x => x.emp.FirstName)</td>
</tr>
<tr>
<td>@Html.LabelFor(x=>x.emp.LastName)</td>
<td>@Html.TextBoxFor(x=>x.emp.LastName)</td>
<td>@Html.ValidationMessageFor(x => x.emp.LastName)</td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" value="Save"/></td>
</tr>
</tbody>
</table>
</div>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script>
$(document).ready(function() {
$('#new').click(function() {
(this).preventDefault();
$('#frm').css('visibility', 'visible');
});
});
</script>
}
任何控制檯錯誤? –
你能確認jQuery實際上正在加載嗎? –
@RajeshJNair未捕獲TypeError:this.preventDefault不是函數 –