最近做手机端的网页开发,对于选择地址这个需求,我去网上弄了个插件,用户体验挺舒服的(挺赞的),但是有一些bug,被我修复了。因为地址是三级联动的,这个地方我也略微改了,也就是说,不用来做选择地址的插件也可以的,比如某些下拉框也可以拿来用。你也可以根据自己需求修改源码。
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Insert title here</title><meta name="apple-mobile-web-app-capable" content="yes"><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"><script src="http://code.jquery.com/jquery-2.1.1.min.js"></script><link rel="stylesheet" type="text/css" href="addresss/css/ydui.css"><script type="text/javascript" src="addresss/ydui.flexible.js"></script></head><body><input type="text" class="cell-input" readonly id="J_Address" value="" placeholder="请选择收货地址"> <input type="text" class="cell-input" readonly id="J_Address2" value="中国 新疆维吾尔自治区 乌鲁木齐市 天山区" placeholder="请选择收货地址"><script type="text/javascript" src="addresss/ydui.citys.js"></script><script type="text/javascript" src="addresss/ydui.js"></script><script> /** * 默认调用 */ !function () { var $target = $('#J_Address'); $target.citySelect(); $target.on('click', function (event) { event.stopPropagation(); $target.citySelect('open'); }); $target.on('done.ydui.cityselect', function (ret) { console.log(ret) $(this).val(ret.country ' ' ret.provance ' ' ret.city ' ' ret.area); }); }(); /** * 设置默认值 */ !function () { var $target = $('#J_Address2'); $target.citySelect({ country: '中国', provance: '新疆维吾尔自治区', city: '乌鲁木齐市', area: '天山区', id: '1-31-330-3033' }); $target.on('click', function (event) { event.stopPropagation(); $target.citySelect('open'); }); $target.on('done.ydui.cityselect', function (ret) { console.log(ret); $(this).val(ret.country ' ' ret.provance ' ' ret.city ' ' ret.area); }); }();</script></body></html>
评论