Is it possible with jQuery to get the value of a select box item based on the selected index? I ask because what I actually need is the value of the items before and after the current selectedindex for next/previous buttons. This is the code I tried but it did not work.
var my_value = $('#my_element_id').attr("selectedIndex").val();
This should do it (after my 3rd edit 🙂 )
It’s quite verbose, but pretty easy to see what it’s doing. I’m sure you can shorten it:
Here is a working example: http://jsfiddle.net/59SPw/
html:
Js: