我无法在具有特定值的选择框中选择一个选项。这是我使用的代码:我做console.log()
的parameters.group
值,所以我知道它等于我想选择选项无法在jQuery mobile中选择具有特定值的选项
$('#group_e option[value="'+parameters.group+'"]').attr("selected", "selected");
。
我在使用Phonegap和jQuery Mobile的XCODE模拟器中执行此操作。
我无法在具有特定值的选择框中选择一个选项。这是我使用的代码:我做console.log()
的parameters.group
值,所以我知道它等于我想选择选项无法在jQuery mobile中选择具有特定值的选项
$('#group_e option[value="'+parameters.group+'"]').attr("selected", "selected");
。
我在使用Phonegap和jQuery Mobile的XCODE模拟器中执行此操作。
您需要刷新选择,以反映不断变化的价值后的变化:
$('#group_e').selectmenu('refresh', true);
谢谢你这工作! –
@SinanSamet:GLAD IT HELPS .. –
1)你不能在'option'上调用'.selectmenu()',它应该在'select'本身上调用。 2)'.selectmenu(“刷新”)'就足够了。 – Omar
的[我如何编程方式从控制自身的变革事件中改变一个选择框选择,并将它移动的工作可能重复浏览器](http://stackoverflow.com/questions/19252664/how-can-i-programmatically-change-a-select-box-selection-from-within-the-control) – Omar