以编程方式更改 selectric 下拉值?

Change value of selectric drop down programmatically?

根据名称以编程方式更改 Selectric 下拉列表值的好方法是什么?我知道我想设置为选中的选项的值。我不知道名称或索引。

这是我最好的尝试:

$('.store-availability').prop('selectedIndex', 3).selectric('refresh').change();

因为我不知道索引,所以我必须先在选项上 jQuery.Index() 才能找到它或类似的东西。有更简洁的方法吗?

如果您知道要设置的选项的值,可以使用 val() 的 setter,然后在 selectric 实例上调用 refresh,如下所示:

$('.store-availability').val(yourValueHere).change().selectric('refresh');