使用jQuery显示/隐藏<select>下拉列表,基于值

iam*_*ick 9 jquery select show-hide option drop-down-menu

我正在尝试构建一个自定义下拉列表,根据它的选择显示/隐藏第二组下拉列表.

我想知道这里是否有人可以帮助解决这个问题.

您可以在http://jsfiddle.net/prodac/stAAm/查看我的代码

aus*_*nbv 7

使用jquery :selected一些文档在这里http://api.jquery.com/selected-selector/

这适用于选项选择菜单

我现在正在更新你的Jfiddle,如果你能给我一些关于你想做什么的更多信息.


编辑

这是一个更新的jfiddle与你的答案. http://jsfiddle.net/stAAm/7/

和Stack溢出代码的副本

$('#source').change(function () {
        if ($('#source option:selected').text() == "France"){
            $('.cities').hide();
            $('#source2a').show();
        } else if ($('#source option:selected').text() == "Germany"){
            $('.cities').hide();
            $('#source2b').show();
        } else if ($('#source option:selected').text() == "India"){
            $('.cities').hide();
            $('#source2c').show();
        } else {
            $('.cities').hide();
        } }); 
Run Code Online (Sandbox Code Playgroud)