【发布时间】:2013-07-04 00:44:11
【问题描述】:
我在一个表单中有很多选择。
我想在表单中的一些选择中添加“其他”选项。选择“其他”时,它显示隐藏的输入。
$(document).ready(function(){
$(".SelectOther").append('<option value=-1>Other</option>');
$(".OtherDiv").hide();
$(".SelectOther").change(function()
{
if($(".SelectOther option:selected").text() == "Other")
{
$(".OtherDiv").show("slide", { direction: "up" }, 1000);
}
else
{
$(".OtherDiv").hide("slide", { direction: "down" }, 1000);
}
});
});
尚未测试此代码,但这会打开所有隐藏的“OtherDiv”
所有选择都在表中的 TD 内。
如何确保选择“其他”时仅显示该 TD 中的隐藏输入?
【问题讨论】:
标签: javascript jquery forms jquery-ui show-hide