Lorraine Bernard
Lorraine Bernard

Reputation: 13400

:not() Selector in a multiple select

I have a multiple select and I need just to access the items which are not selected

I tried the following code but it does not work because it returns also the selected items. Any hints how to fix this code?

$('select.myMultippleSelect option:not(selected)');

[
<option value=​"13">​Normal User​</option>​
, 
<option value=​"14" selected=​"selected">​Euna Baumbach​</option>​
, 
<option value=​"15">​Test​</option>​
]

Upvotes: 2

Views: 58

Answers (2)

Pranay Rana
Pranay Rana

Reputation: 176896

check this out its working for me , you forgot to include : before selected in you code , updated code is

$('select.myMultippleSelect option:not(:selected)');

DEMO

Upvotes: 1

Paystey
Paystey

Reputation: 3242

There's a typo, should be a : before selected. Does that exist in your code? If it does, there's your problem.

Upvotes: 1

Related Questions