给定以下jQuery插件:
http://selectric.js.org/index.html
通过使用自定义UL LI列表取代常规选择框的功能,
根据插件文档,我知道如果您已经知道要选择的索引,可以使用以下代码以编程方式选择选项值:
$('#idofselectbox').prop('selectedIndex', 3).selectric('refresh');
但它们不包括能够通过值查找和选择选项值的样本。
例如
假设我想选择名为“apples”的选项值,而不知道它在选择框中的索引。这有可能吗?
<select id="idofselectbox">
<option value="oranges">oranges</option>
<option value="pears">pears</option>
<option value="apples">apples</option>
<option value="strawberries">strawberries</option>
</select>