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.
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.
I am trying the following:
$('#segmentCrossStreet1:not(:selected)')
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/ (this fiddle also shows how to pupulate another <select>
)
You have to select the <option>
elements, rather than the "selected <select>
" elements:
$('#segmentCrossStreet1 option:not(:selected)');
Your current selector:
$('#segmentCrossStreet1:not(:selected)')
Searches for all #segmentCrossStreet1
elements that are not selected. Is this what you want? I doubt it. Add a space before :not(
to search for child elements:
$('#segmentCrossStreet1: not(:selected)')
Better if you made it more specific:
$('#segmentCrossStreet1: option:not(:selected)')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With