【发布时间】:2018-03-28 06:30:55
【问题描述】:
我正在尝试使用 Javascript 从浏览器开发人员工具的下拉菜单中选择所需的值。下图为页面内容。
但是每当我使用代码选择另一个值然后单击保存按钮时,实际上并没有保存更改。当我用鼠标正常选择并单击保存按钮时,它会正常更改。
我尝试了以下内容。这些似乎改变了所选下拉菜单的值(我写代码时显示为 2),但之后无法保存。
1-document.getElementById('channel24g_ctrl')[2].selected = true
2-document.getElementById('channel24g_ctrl').options.selectedIndex = 2
3-document.getElementById('channel24g_ctrl').options[2].selected = true
4-document.getElementById('channel24g_ctrl').options[2].click()
5-document.getElementById('channel24g_ctrl').options[2].setAttribute("selected", "selected");
document.getElementById('channel24g_ctrl').options[1].removeAttribute("selected");
我可能已经尝试了上述组合的其他一些组合。 只有第五个实际上使目标选项“被选中”,但单击保存按钮时它仍然不起作用。我不是 javascript 或 ember 方面的专家,但我之前在其他网站上做过类似的事情并取得了成功。那么问题可能出在 Ember 框架上?
我还能做什么?
【问题讨论】:
标签: javascript developer-tools