city-picker
city-picker copied to clipboard
请问一下, 有不有根据code能直接取出对应的值?
请问一下, 有不有根据code能直接取出对应的值?
修改city-picker.js 找到getCode这一行,大概在358行左右, 在下面添加方法: getValue: function (count) { var text = ''; this.$dropdown.find('.city-select') .each(function () { if($(this).hasClass(count)){ var item = $(this).data('item'); text = item.address; return text; } }); return text; },
调用: 省:$("#prov").val($("#city-picker").data("citypicker").getValue("province")); 市:$("#city").val($("#city-picker").data("citypicker").getValue("city")); 县:$("#county").val($("#city-picker").data("citypicker").getValue("district"));