企鹅 通过本文主要向大家介绍了jQuery,TAB,全国省份城市,滑动切换等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
本文实例讲述了jQuery实现TAB风格的全国省份城市滑动切换效果代码。分享给大家供大家参考。具体如下:
这里演示jQuery实现的全国省市菜单,加入了选项卡风格,把全国城市按字母范围归类,鼠标移到某一分类的时候,滑动门展开显示所属的全国省分和城市。特别适合于分类信息网站使用。当然,在需要选择省市的时候,也是可以用的。仔细看了下,菜单里面的城市还比较全,你不用再手动添加城市了。
运行效果截图如下:

在线演示地址如下:
http://demo.jb51.net/js/2015/jquery-tab-cha-city-menu-style-codes/
具体代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery全国城市切换TAB选项卡</title>
<style type="text/css">
*{margin:0;padding:0;border:0;font-size:12px;}
a{text-decoration:none;}
ul,li,ol,dl,dt,dd{list-style:none;}
.cityList{display:block;position:absolute;left:20px;top:20px;width:676px;border:2px solid #B91313;background:white;z-index:1;overflow:hidden;font-family:arial,"宋体";overflow:hidden;}
.cityList .title{background-color:#F4F4F4;width:100%;padding-top:10px;padding-left:16px;overflow:hidden;position:relative;}
.cityList .cityTopSearch{float:left;width:228px;height:25px;line-height:25px;margin-right:38px;padding:0 2px;display:inline;border:1px solid #E6DFDE;color:#5e5e5e;}
.cityList ul.titleChar{list-style:none;cursor:default;}
.cityList .titleChar .on{border-color:#E6DFDE;background-color:white;}
.cityList .titleChar li{float:left;border:1px solid #F4F4F4;border-bottom:0;padding:6px 24px;}
.cityList .cityListBox{margin:8px 0 0 16px;color:#686868;overflow:hidden;display:inline-block;_position:relative;}
.cityListBox dl{position:relative;overflow:hidden;zoom:1;}
cityListBox .hotCity dd{width:650px;}
.cityListBox dl dt{float:left;width:20px;height:auto;display:block;line-height:25px;}
.cityListBox dl dd{float:left;line-height:25px;_padding-top:2px;text-align:left;width:640px;margin-bottom:6px;}
.cityListBox dl dd a{color:#686868;}
.cityListBox dl dd a:hover{color:#990000;text-decoration:underline;}
.cityListBox a{width:55px;display:inline-block;}
.none{display:none;}
</style>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$change_li = $(".titleChar li");
$change_li.each(function(i){
$(this).mouseover(function(){
$(this).addClass("on").siblings().removeClass("on");
$(".cityListBox dl").eq(i).show().siblings().hide();
})
});
});
</script>
</head>
<body>
<div class="cityList">
<div class="title">
<input type="text" id="" class="cityTopSearch" value="请输入城市或城市拼音" maxlength="15" />
<ul class="titleChar">
<li class="on">热门</li>
<li>A~G</li>
<li>H~L</li>
<li>M~T</li>
<li>W~Z</li>
</ul>
</div>
<div class="cityListBox">
<dl class="hotCity">
<dd>
<a href="#">北京</a>
<a href="#">上海</a>
<a href="#">广州</a>
<a href="#">深圳</a>
<a href="#">杭州</a>
<a href="#">南京</a>
<a href="#">成都</a>
<a href="#">重庆</a>
</dd>
</dl>
<dl class="none">
<dt>A</dt>
<dd>
<a href="#">安宁</a>
<a href="#">安康</a>
<a href="#">安顺</a>
<a href="#">安阳</a>
<a href="#">安庆</a>
<a href="#">鞍山</a>
</dd>
<dt>B</dt>
<dd>
<a href="#">毕节</a>
<a href="#">霸州</a>
<a href="#">巴中</a>
<a href="#">白山</a>
<a href="#">保山</a>
<a href="#">百色</a>
<a href="#">巴彦淖尔</a>
<a href="#">白银</a>
<a href="#">亳州</a>
<a href="#">北海</a>
<a href="#">本溪</a>
<a href="#">蚌埠</a>
<a href="#">保定</a>
<a href="#">滨州</a>
<a href="#">包头</a>
<a href="#">宝鸡</a>
<a href="#">北京</a>
</dd>
<dt>C</dt>
<dd>
<a href="#">从化</a>
<a href="#">长葛</a>
<a href="#">赤壁</a>
<a href="#">承德</a>
<a href="#">昌吉</a>
<a href="#">池州</a>
<a href="#">巢湖</a>
<a href="#">长治</a>
<a href="#">赤峰</a>
<a href="#">潮州</a>
<a href="#">滁州</a>
<a href="#">沧州</a>
<a href="#">常熟</a>
<a href="#">郴州</a>
<a href="#">常德</a>
<a href="#">常州</a>
<a href="#">长春</a>
<a href="#">长沙</a>
<a href="#">楚雄</a>
<a href="#">慈溪</a>
<a href="#">成都</a>
<a href="#">重庆</a>
</dd>
<dt>D</dt>
<dd>
<a href="#">敦煌</a>
<a href="#">大丰</a>
<a href="#">都匀</a>
<a href="#">东阳</a>
<a href="#">东港</a>
<a href="#">迪庆</a>
<a href="#">丹江口</a>
<a href="#">大石桥</a>
<a href="#">丹阳</a>
<a href="#">定西</a>
<a href="#">都江堰</a>
<a href="#">达州</a>
<a href="#">大同</a>
<a href="#">大庆</a>
<a href="#">丹东</a>
<a href="#">德州</a>
<a href="#">德阳</a>
<a href="#">东营</a>
<a href="#">大理</a>
<a href="#">大连</a>
<a href="#">东莞</a>
</dd>
<dt>E</dt>
<dd>
<a href="#">鄂尔多斯</a>
<a href="#">鄂州</a>
<a href="#">恩施</a>
</dd>
<dt>F</dt>
<dd>
<a href="#">福建</a>
<a href="#">福清</a>
<a href="#">阜阳</a>
<a href="#">抚州</a>
<a href="#">防城港</a>
<a href="#">阜新</a>
<a href="#">抚顺</a>
<a href="#">富阳</a>
<a href="#">佛山</a>
<a href="#">福州</a>
</dd>
<dt>G</dt>
<dd>
<a href="#">盖州</a>
<a href="#">固原</a>
<a href="#">高邮</a>
<a href="#">广汉</a>
<a href="#">贵港</a>
<a href="#">赣州</a>
<a href="#">贵阳</a>
<a href="#">桂林</a>
<a href="#">广州</a>
</dd>
</dl>
<dl class="none">
<dt>H</dt>
<dd>
<a href="#">华蓥</a>
<a href="#">侯马</a>
<a href="#">鹤山</a>
<a href="#">洪湖</a>
<a href="#">怀化</a>
<a href="#">淮北</a>
<a href="#">衡水</a>
<a href="#">河池</a>
<a href="#">鹤岗</a>
<a href="#">海门</a>
<a href="#">鹤壁</a>
<a href="#">海安</a>
<a href="#">黄冈</a>
<a href="#">汉中</a>
<a href="#"&

