问题描述
我有两个相关的下拉菜单.
I have two related dropdowns.
当用户从第一个下拉列表中选择一个选项时,第二个下拉列表会填充第一个下拉列表中未选择的所有选项的列表.
When the user selects an option from the first drop down, the second drop down is populated with a list of all the options from the first drop down that were NOT selected.
我正在尝试使用 jquery 来获取所有未选中的选项,但我仍然是 jquery 新手并且一定是缺少某些东西.
I'm trying to use jquery to get all the not selected options, but I'm still a jquery newb and must be mising something.
我正在尝试以下操作:
$('#segmentCrossStreet1:not(:selected)')
这就是segmentCrossStreet1"是第一个下拉菜单的 ID.这似乎没有返回任何有用的东西.我做错了什么?
This is where "segmentCrossStreet1" is the ID of the first drop down. This doesn't appear to return anything useful. What am I doing wrong?
推荐答案
Fiddle: http://jsfiddle.net/uzhWS/(这个小提琴还展示了如何生成另一个 )
您必须选择 元素,而不是selected
"元素:
You have to select the <option>
elements, rather than the "selected <select>
" elements:
$('#segmentCrossStreet1 option:not(:selected)');
这篇关于从下拉列表中获取未使用 jquery 选择的值列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!