我已经使用了几次,通常效果很好。然而,在我最近的使用中,隐藏的 div 会很好地向下滑动,但不会重新向上。单击“是”单选按钮时应该向下滑动,单击“否”时应该向后滑动。这时候无论点击单选按钮它都会向下滑动,不会向上滑动。我认为它总是看到一个“是”的价值..
这是html:
<div id="AliasSectionTop">
Have you ever been known by another name (maiden name, name change, etc)?
<input type="radio" value="Yes" name="aliasName" />Yes
<input type="radio" value="No" name="aliasName" />No
</div>
<div id="AliasSectionBottom" class="hidden">
@for (var i = 0; i < 5; i++)
{
<div class="formGroup">
<div class="editor-label">
@Html.Label("First Name")
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.PersonAliasModel[i].FirstNameAlias)
</div>
</div>
<div class="formGroup">
<div class="editor-label">
@Html.Label("Last Name")
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.PersonAliasModel[i].LastNameAlias)
</div>
</div>
}
</div>
这是jQuery:
// SHow full form once the waiver checkboix is checked.
$(document).ready(function () {
$("input[name=aliasName]").click(function () {
if ($("input[name=aliasName]").val() == "Yes") {
$("#AliasSectionBottom").slideDown(800);
} else {
$("#AliasSectionBottom").slideUp("fast");
}
});
});