<!DOCTYPE html> | |
<html> | |
<body> | |
<select> | |
<option selected>Apple</option> | |
<option>Orange</option> | |
<option>Banana</option> | |
</select> | |
<script> | |
var comboBox = document.querySelector('select'); | |
comboBox.focus(); | |
// Expand the combo box. | |
var clickEvent = document.createEvent('MouseEvents'); | |
clickEvent.initMouseEvent('mousedown', true, true, window); | |
comboBox.dispatchEvent(clickEvent); | |
function go() { | |
document.querySelector('select').selectedIndex = 1; | |
} | |
</script> | |
</body> | |
</html> |