显示/隐藏< select>下拉菜单,用jQuery,基于值 [英] Show/Hide <select> dropdown, with jQuery, based on value
问题描述
我正在尝试建立一个自定义下拉列表,根据选择显示/隐藏第二组下拉列表。
I'm trying to build a custom dropdownlist wich show/hide a second set of dropdowns based on it's selection.
我想知道这里是否有人可能帮助解决这个问题。
I was wondering if anyone here might be able to help with a solution to this.
您可以在 http: //jsfiddle.net/prodac/stAAm/
推荐答案
使用jquery :selected
这里有一点文档是 http://api.jquery.com/选择选择器/
use the jquery :selected
a little bit of documentation is here http://api.jquery.com/selected-selector/
在选项选择菜单中使用
我正在更新您的Jfiddle现在,如果你能给我一些关于你想做什么的信息。
I am updating your Jfiddle now if you can give me a little more info about what you want done.
修改
这是一个更新的jfiddle你的答案。
http://jsfiddle.net/stAAm/7/
Here is an updated jfiddle with your answer. http://jsfiddle.net/stAAm/7/
和堆栈溢出代码的副本
$('#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();
} });
这篇关于显示/隐藏< select>下拉菜单,用jQuery,基于值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!