3

I have this command (visibleSelect is jquery variable that holds multiple select list):

var selectedOption = visibleSelect.find('option[selected=true]');

From the watch window I can see that selectedOption.length is 0, but visibleSelect.get(0)[1].selected is true.

Why selectedOption doesn't containt the selected option? What is wrong?

Naor
  • 23,465
  • 48
  • 152
  • 268

3 Answers3

4

Try

var selectedOption = visibleSelect.find('option:selected');
marramgrass
  • 1,411
  • 11
  • 17
4

use var selectedOption = visibleSelect.find('option:selected');

El Ronnoco
  • 11,753
  • 5
  • 38
  • 65
2

Description

The correct attribute value is checked="checked". But Anyway you should use the jQuery :selected selector to guarantee cross browser compatility.

visibleSelect.find('option:selected');

More Information

Community
  • 1
  • 1
dknaack
  • 60,192
  • 27
  • 155
  • 202