移动端滑动选择城市
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<title></title>
<style type="text/css">
* {
margin: 0;
padding: 0;
-webkit-appearance: none; //去掉浏览器默认样式
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-touch-callout: none;
box-sizing: border-box;
}
html,
body {
margin: 0 auto;
width: 100%;
min-height: 100%;
overflow-x: hidden;
-webkit-user-select: none;
}
body {
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
-webkit-text-size-adjust: 100%; //关闭自动调整字体
-webkit-overflow-scrolling: touch;
overflow-scrolling: touch;
}
input {
width: 90%;
height: 40px;
font-size: 18px;
border: 1px solid #eee;
border-radius: 5px;
margin: 20px 5% 0 5%;
padding: 5px;
font-size: 14px;
color: #555;
}
h1 {
background-color: #b72f20;
color: #fff;
font-size: 25px;
text-align: center;
padding: 10px;
}
</style>
<link rel="stylesheet" href="css/LArea.css">
</head>
<body>
<div>
<div class="content-block">
<input id="demo1" type="text" readonly="" placeholder="城市选择特效" value="北京市,东城区," />
<input id="value1" type="hidden" value="20,234,504" />
</div>
</div>
<script src="js/LAreaData1.js"></script>
<script src="js/LAreaData2.js"></script>
<script src="js/LArea.js"></script>
<script>
var area1 = new LArea();
area1.init({
'trigger': '#demo1', //触发选择控件的文本框,同时选择完毕后name属性输出到该位置
'valueTo': '#value1', //选择完毕后id属性输出到该位置
'keys': {
id: 'id',
name: 'name'
}, //绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出
'type': 1, //数据源类型
'data': LAreaData //数据源
});
area1.value=[1,15,3];//控制初始位置,注意:该方法并不会影响到input的value
var area2 = new LArea();
area2.init({
'trigger': '#demo2',
'valueTo': '#value2',
'keys': {
id: 'value',
name: 'text'
},
'type': 2,
'data': [provs_data, citys_data, dists_data]
});
</script>
</body>
</html>