【问题标题】:How would I auto select a drop down picker view in a UIWebView without using .selectedIndex =?如何在不使用 .selectedIndex = 的情况下自动选择 UIWebView 中的下拉选择器视图?
【发布时间】:2014-01-12 23:15:46
【问题描述】:

我用过[_webView stringByEvaluatingJavaScriptString@"document.getElementById('ELEMENTNAME').value = 'NAME OF VALUE I WANT'"];

但这不起作用。提前谢谢!

【问题讨论】:

  • 请在问题中写出整个问题,不要将主题用作问题的一部分。

标签: javascript objective-c webview element


【解决方案1】:

您应该改用 selectedIndex 属性。

例如,如果要选择第三个选项,请使用

document.getElementById('ELEMENTNAME').selectedIndex = 2 //Index of the option.

对于第 6 个选项,请使用

document.getElementById('ELEMENTNAME').selectedIndex = 5 //Index of the option.

【讨论】:

  • 谢谢你,我已经这样做了,它可以工作,但是我需要它根据选项的名称而不是顺序来选择选项。谢谢
猜你喜欢
  • 2021-12-26
  • 1970-01-01
  • 2018-12-12
  • 1970-01-01
  • 2013-10-15
  • 2019-07-27
  • 2015-02-23
  • 2015-12-22
  • 1970-01-01
相关资源
最近更新 更多