What is best way to navigate select option using next/previous button with jquery? I have a select list when change also changes some div. Instead of just a dropdown, I want
Something like this should work -
$("#next").click(function() {
$("#mycars").val($("#mycars > option:selected").next().val());
})
$("#prev").click(function() {
$("#mycars").val($("#mycars > option:selected").prev().val());
})
Interestingly this will "wrap-around" (go back to the 'Volvo' option after 'Audi') when using the next button but stop at the 'Volvo' option when using the 'Previous' button. Here's a demo -
http://jsfiddle.net/aQSSG/