<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery手机端世界城市地区四级联动菜单代码</title>
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<link rel="stylesheet" href="css/ydui.css">
<link rel="stylesheet" href="css/demo.css">
<script src="js/ydui.flexible.js"></script>
</head>
<body>
<section class="g-flexview">
<section class="g-scrollview">
<div class="m-celltitle">默认调用</div>
<div class="m-cell">
<div class="cell-item">
<div class="cell-left">所在地区:</div>
<div class="cell-right cell-arrow">
<input type="text" class="cell-input" readonly id="J_Address" value="" placeholder="请选择收货地址">
</div>
</div>
</div>
<div class="m-celltitle">设置默认值</div>
<div class="m-cell">
<div class="cell-item">
<div class="cell-left">所在地区:</div>
<div class="cell-right cell-arrow">
<input type="text" class="cell-input" readonly id="J_Address2" value="中国 新疆维吾尔自治区 乌鲁木齐市 天山区" placeholder="请选择收货地址">
</div>
</div>
</div>
</section>
</section>
<script src="js/jquery.min.js"></script>
<script src="js/ydui.citys.js"></script>
<script src="js/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>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
<p>适用浏览器:360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗. 不支持IE8及以下浏览器。</p>
<p>来源:<a href="http://www.lanrenzhijia.com/" target="_blank">懒人</a></p>
</div>
</body>
</html>