开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜