Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - how can I get a value of the next option in a dropdown after the selected one?

I have a drop down with a selected option at index = 0. How can I in jquery get the value of the next option at index = 1? Of course I need to do that without specifying the value of the next option because I can;t assume what it will be at this point.

thx

like image 203
goe Avatar asked Apr 12 '11 13:04

goe


2 Answers

You can write

$('#dropDownId option:selected').next().val()

Or

$('#dropDownId option:selected+option').val()
like image 83
SLaks Avatar answered Nov 15 '22 07:11

SLaks


 $('#selectid option:selected').next().val()
like image 23
mcgrailm Avatar answered Nov 15 '22 07:11

mcgrailm