I have a Select Box where multiple option can be selected. Now I would like to get value of a particular index. How can I do this? For example I have a select box which have following values:
0 - Apple 1 - Orange 2 - Banana 3 - Pineapple
Now I would like to get value of index 2 which is Banana. How can I do this in jQuery?
If the select box has the same values for value and text, you can get the value for the 2nd select using
eq()andval()like this:If the select has numeric values and text, you can get the text "Banana" using
eq()andtext():And in case you want to get the value of the option with the text "Banana" you can do this using
filter():