Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check if multiple select has option selected

I have the next select:

<select name="extra_especialidad[]" multiple="multiple">

For any reason the name is comming with brackets and I can't change or add anything to the element.

I am trying to check if the select has any option selected, I have tried this without success...

$("input[name=extra_especialidad\\[\\]]").length; //Gives me 0 always
$("input[name=extra_especialidad\\[\\]]").val().length; //gives me error

Any advice?

Thanks in advance.

like image 350
notforever Avatar asked May 19 '14 23:05

notforever


Video Answer


1 Answers

You may try this (Example):

$("select[name='extra_especialidad[]'] option:selected").length;
like image 81
The Alpha Avatar answered Oct 05 '22 03:10

The Alpha