tags:

views:

110

answers:

1

How can i get the unselected items from dropdown using jQuery

+5  A: 
$('select#xyz option:not(:selected)');

or

$('#mySelect option').not(':selected');
Moin Zaman
`"select#xyz"` as a selector is actually slower than `"#xyz"`. The latter looks into `document.getElementbyId()`, which is easily the fastest way of selecting.
James Wiseman
@James is correct...also I can't think of an instance where this would be an efficient way to solve the problem :)
Nick Craver
I wanted to show clearly that I was selecting a select.
Moin Zaman
@Nick: efficient way to select unselected options in a dropdown? or are you referring to why select them in the first place as the questioner asked? if the former, then what's efficient?
Moin Zaman
@Moin - Both :) `$("#xyz").val() != "something"` would typically be how to go about this, `#xyz` instead of `select#xyz` and `[selected]` would be the most efficient, but my point was more of selecting the options in the first place, a bad approach by the OP I imagine, but maybe there's some wacky valid reason for this I can't imagine....
Nick Craver