开发者

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

开发者 https://www.devze.com 2023-02-24 19:34 出处:网络
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?

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开发者_Python百科 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


You can write

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

Or

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


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


Try:

$('#selectId>option:selected').next().val()
0

精彩评论

暂无评论...
验证码 换一张
取 消