我用于jQuery Mobile自定义选择菜单的.change菜单根本没有触发。我正在尝试动态添加jQuery Mobile选择菜单:
附加jQuery Mobile选择菜单
$('#visSelectionMenu').append('<div data-role="fieldcontain"><label for="visMenu" class="select">Select Visualization:</label><select name="visMenu" id="visMenu" data-native-menu="false" class="visualizationMenu">');
var visualizationList = ['Triangle','Square'];
for (var i = 0; i < visualizationList.length; i++) {
$('#visMenu').append('<option value=\'' + visualizationList[i] + '\'>' + visualizationList[i] + '</option>');
}
$('#visMenu').selectmenu();
$("#visMenu").selectmenu('refresh', true);
OnChange方法
$("#visMenu").change(function () {
console.log("hello");
var $this = $(this),
val = $this.val();
alert('onChange = ' + val);
});