You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!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>HTML5手机三级联动城市选择代码</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 #b72f20;
border-radius: 5px;
margin: 20px 5% 0 5%;
padding: 5px;
}
/*
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 class="content-block">
<input id="demo2" type="text" readonly="" placeholder="城市选择特效" value="天津市,市辖区,和平区"/>
<input id="value2" type="hidden" value=""/>
</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,13,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>