我正在尝试动态创建一个
以下是一个可运行的jsFiddle
示例: http://jsfiddle.net/Gajotres/dEXac/
$(document).on('pagebeforeshow', '#index', function(){
// Add a new select element
$('<select>').attr({'name':'select-choice-1','id':'select-choice-1'}).appendTo('[data-role="content"]');
$('<option>').attr({'value':'1'}).html('Value 1').appendTo('#select-choice-1');
$('<option>').attr({'value':'2'}).html('Value 2').appendTo('#select-choice-1');
// Enhance new select element
$('select').selectmenu();
});
这个对我有效
$(document).on('change', "body", function(){
$( ".ui-selectmenu" ).selectmenu();
});
$('<select name="sl" id="sl" data-native-menu="false"><option value="clear">That I got</option></select>').appendTo("#output");
$('<option value="clear2">Another That I got</option>').appendTo("#sl");
$('select').selectmenu();