標籤:
一、外掛程式介紹
最早做省市聯動的時候都特別麻煩,後來在helloweba的一篇文章中看到這個外掛程式,很不錯的,後來就一直用了。
省市區聯動下拉效果在WEB中應用非常廣泛,尤其在一些會員資訊系統、電商網站最為常見。開發人員一般使用Ajax實現無重新整理下拉聯動。本文將講述,利用jQuery外掛程式,通過讀取JSON資料,實現無重新整理動態下拉省市二(三)級聯動效果。
二、外掛程式作者及網址
暫無(請作者看到後聯絡我[email protected],好標上你的大名)
官方網址:無
官方DEMO:無
最新版本:日期2012-7-18
三:外掛程式參數
| 參數名 |
預設值 |
字元類型 |
使用頻率 |
釋義說明 |
| url |
js/city.min.js |
string |
常用 |
省市資料josn檔案路徑 |
| prov |
null |
string |
常用 |
預設省份 |
| city |
null |
string |
常用 |
預設城市 |
| dist |
null |
boolean |
常用 |
預設地區(縣) |
| nodata |
null |
string |
常用 |
無資料狀態 |
| required |
true |
boolean |
常用 |
必選項 |
下載參數文檔 http://www.ijquery.cn/demo/cityselect/cityselect.js參數說明.xls
四:外掛程式案例
1、本站案例
a>demo1 http://www.ijquery.cn/demo/cityselect
下載 http://www.ijquery.cn/demo/cityselect/cityselect.zip
五:最簡使用教程
樣本:http://www.ijquery.cn/demo/cityselect/simple.html
1、HTML代碼
<div id="city"> <select class="prov"></select> <select class="city" disabled="disabled"></select> <select class="dist" disabled="disabled"></select> </div>
2、JS和CSS代碼 ,請注意這裡預設需要把城市資料庫 city.min.js 放到 jquery.cityselect.js 所在的資料庫中,千萬不要丟失!
<script type="text/javascript" src="js/jquery.js"></script><script type="text/javascript" src="js/jquery.cityselect.js"></script><script type="text/javascript">$(function(){$("#city").citySelect({nodata:"none",required:false}); });</script>
為方便可以直接引用絕對位址
這裡的city.mini.js的絕對位址在 http://www.ijquery.cn/js/cityselect/city.min.js
<script type="text/javascript" src="http://www.ijquery.cn/js/jquery.js"></script><script type="text/javascript" src="http://www.ijquery.cn/js/cityselect/jquery.cityselect.js"></script><script type="text/javascript">$(function(){$("#city").citySelect({nodata:"none",required:false}); });</script>
繼續瀏覽有關 Jquery外掛程式聯動外掛程式表單外掛程式進階頁面 的文章
jquery.cityselect.js基於jQuery+JSON的省市或自訂聯動效果