Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

option[selected=true] doesn't work

Tags:

jquery

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?

like image 755
Naor Avatar asked Feb 04 '26 04:02

Naor


2 Answers

Try

var selectedOption = visibleSelect.find('option:selected');
like image 107
marramgrass Avatar answered Feb 05 '26 22:02

marramgrass


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

like image 34
El Ronnoco Avatar answered Feb 05 '26 21:02

El Ronnoco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!