Is there a way to programmatically click on a combobox item?
I've been trying experiments with the following, but so far to no开发者_如何学编程 avail:
sel = document.getElementById('myComboBox')
sel.selectedIndex = 1;
sel.options[1].selected = true;
sel[1].click();
Thanks for the help!
Wait why would you write:
sel.options[1].selected = true;
and then in the very next line write
sel[1].click();
?? The element is not an array and can't be treated as one.
The "click" event might not be the best thing to handle anyway. Probably the "change" event on the select element itself would be more reliable.
精彩评论