我会给你如何做点为例两个在你的列表中。由此你应该能够为其他人调整解决方案。我假设三个选择框的ID为first
,second
和third
。
$("#first").change(function() {
//Reset so that all options are enabled and visible.
$("option").prop("disabled", false).show();
//Do different things depending on what value is selected.
switch($(this).val())
{
case "1":
//Implement some code here.
break;
case "2":
//Hide a option on the second select.
$("#second option[value=a]").hide();
//Disable 6 option on third select.
$("#third option[value=6]").prop("disabled", true);
break;
case "3":
//Implement some code here.
break;
}
});
请注意,此代码依赖于value
属性被显式的选项设置。您也可以根据列表中的位置来选择选项,例如#third option:eq(2)
作为第三个列表中的第三个选项。
您可能还想添加一些逻辑,以便在删除或禁用某个选项时选择其他选项。
Fiddle.
什么您已经尝试到现在? –
对不起Sarjan.I已经搜索Google.But即时通讯没有得到help.I想让它交互像在C++或C languange.If在C + +或C我可以很容易地设置文本框属性为false通过触发一些附加到它的事件但现在它的网络,我真的不知道。你可以给我一点例子。我自己来休息一下。谢谢 –