不多說,直接上代碼
首先需要導入三個js 檔案
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="js/province/distpicker.data.js"></script>
<script type="text/javascript" src="js/province/distpicker.js"></script>
頁面如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="js/province/distpicker.data.js"></script>
<script type="text/javascript" src="js/province/distpicker.js"></script>
<script language="JavaScript">
$(function(){
/*城市選擇控件*/
$("#distpicker1").distpicker();
/*
$("#distpicker1").distpicker({
province: a,
city: b,
district: c,
autoSelect: true,
placeholder: false
});
*/
})
function refreshAAA(){
console.log( $("#province").val() );
alert($("#province").val());
}
</script>
</head>
<body>
<div id="distpicker1">
<select id="province" name="province" class="select" style="width:180px;height:31px;" onchange="refreshAAA()"></select>
<select id="city" name="city" class="select" style="width:180px;height:31px;" onchange="refreshAAA()"></select>
<select id="district" name="district" class="select" style="width:180px;height:31px;" onchange="refreshAAA()"></select>
</div>
</body>
</html>