mobiscroll_2.15.1
var opt_sex = { theme: 'ios', lang: 'zh', formatValue: function (d) { return d.join(','); }, customWheels: true, wheels: [//如果值非常多请事先按需求生成好 [ { values: ['男', '女', ], keys: [1, 2] } ], [ { values: [''], keys: [0] } ] ], onChange: function (valueText, inst) { var json = eval("[" + valueText + "]"); //cityData城市数据集 json var jsonmsg = cityData[json[0].keys]; var cityValues = new Array(); var cityKeys = new Array(); for (var i = 1; i < jsonmsg.length; i++) { cityValues.push(jsonmsg[i].cityname); cityKeys.push(jsonmsg[i].cityid); } inst.settings.wheels[1][0].values = cityValues; inst.settings.wheels[1][0].keys = cityKeys; //通过changeWheel来实现联动效果 sexs.mobiscroll('changeWheel', [0,1]); }, onSelect: function (valueText, inst) { var json = eval("[" + valueText + "]"); $("#user_sex").val(json[0].values); $("#hid_sex").val(json[0].keys); }, onShow: function () { //指定选项 var num = $("#hid_sex").val(); sexs.mobiscroll('selectWheel', [num], 1000, true); } }; var sexs = $('input[data-time=sex]').mobiscroll(opt_sex);