Firing down arrow key press in a select box via javascript
问题 For strange reasons I have to change the selected element in a dropdownbox not via e.selectedIndex, but via the simulation of mouse and keypress events. I tried the following: //e = the dropdown e.focus(); //my custom function to fire mouse events. This opens the dropdown. fireMouseEvent("mousedown", e); //firing the key press, tried it via keydown, keypress and keyup. Nothing works. var evt = e.ownerDocument.createEvent("KeyEvents"); evt.initKeyEvent("keydown", true, true, null, false, false