I have a select with f.e. 10 options (‘one’, ‘two’, ‘three’, …). Loading the page the first option ‘one’ is selected.
Within a function I set to fifth option
$("myselect").val('five');
In fact now fifths option is shown in select and value also is set correct.
But now I tab on in my form until I reach this select. And if I now use keyboard down key, the select jumps to option ‘two’ and not ‘six’.
How to set a selected option which works for a later keyboard use, too?
Try setting the
selectedIndexproperty. See below,DEMO: http://jsfiddle.net/kLZ7z/
Another better cleaner approach is
DEMO: http://jsfiddle.net/kLZ7z/2/