@if (ViewBag.ReportType == "TESTING")
{
<tr id="row_test">
<td>ZONE :</td><td> @Html.DropDownList("zone", (IEnumerable<SelectListItem>)ViewBag.zone, new { style = "width:350px"})</td>
<td>STATE :</td><td> @Html.DropDownList("state", (IEnumerable<SelectListItem>)ViewBag.state, new { style = "width:350px"})</td>
<td>COUNTRY:</td><td> @Html.DropDownList("country", (IEnumerable<SelectListItem>)ViewBag.country, new { style = "width:350px"})</td>
</tr>
}
這是我想在這里輸入的剃須刀代碼
$("#reportType").change(function () {
if ($(this).val() == "TESTING") {
var testRow = $("#reportType").append($('#row_test').clone()); //this part here is the problem, its not working
$(testRow).insertAfter("#filter_section");
$("#zone").focus();
$("#state").focus();
$("#country").focus();
} else {
$("#row_test").remove();
}
});
為什么這不起作用?如果用戶單擊的值是 TESTING,則應該顯示該行。但是它沒有出現。
#Edit 1:添加reportType以進一步澄清
<div style="height:850px">
<section class="container">
<table style="width:850px;">
<tr id="filter_section">
@*<td style="width:185px;"></td> *@
<td style="width:120px">REPORT :</td>
<td> @Html.DropDownList("reportType", (IEnumerable<SelectListItem>)ViewBag.ReportType, new { style = "width:350px" })</td>
@*<td style="width:185px;"></td> *@
</tr>
報告型別的目的是當用戶單擊報告型別的下拉串列并單擊 TESTING 時,應該會出現另外三個下拉串列,分別是區域、州和國家
uj5u.com熱心網友回復:
它實際上用更少的代碼更簡單,顯示和隱藏功能是讓它作業的功能,附在下面:
$("#reportType").change(function () {
if ($(this).val() == "TESTING") {
$('#row_test').show();
} else {
$("#row_test").hide();
}
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/512240.html
標籤:C#jQueryasp.net 核心视觉工作室 2010剃刀
上一篇:如何直接或間接從MicrosoftHTMLHelpWorkshop1.4(.chm)遷移到新的HelpViewer(.mshc)格式
下一篇:vb.net不支持給定路徑的格式
