0
我有我的Dropdownbox名單.cshtml
如下:asp.net mvc的顯示/隱藏DIV時Dropdownbox選項更改
<div class="form-group">
@Html.Label("Role", new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.DropDownList("Name", null, new { @class = "form-control" })
</div>
</div>
這是我第一次和第二div
。
<div class="StudentSection" style="display:none;">
Some contents
</div>
<div class="LecturerSection" style="display:none;">
Some contents
</div>
在.js
<script type="text/javascript">
$(document).ready(function() {
$("#StudentSection").hide();
$("#LecturerSection").hide();
$("#Name").change(function() {
if ($("#Name").val() == "Student") {
$("#StudentSection").show();
$("#LecturerSection").hide();
}
else {
$("#LecturerSection").show();
$("#StudentSection").hide();
}
});
});
</script>
這些代碼不爲我的作品提供了我的代碼。
Thanksss了很多! :)這幫助我了! – H2O
apvote答案,如果它幫助:) – jafarbtech