search
HomeWeb Front-endJS TutorialjQuery realizes sliding switching between provinces and cities (with code)

This time I will bring you jQuery to realize sliding switching of provinces and cities (with code). What are the precautions for jQuery to realize sliding switching of provinces and cities. The following is a practical case, let's take a look.

Here is a demonstration of the national province and city menu implemented by jQuery. A tab style is added to classify the cities across the country by letter range. When the mouse is moved to a certain category, the sliding door expands to display the national provinces and provinces to which it belongs. City. Especially suitable for classified information websites. Of course, it can also be used when you need to select a province or city. After looking carefully, the cities in the menu are relatively complete, and you don’t need to add cities manually.

The screenshot of the running effect is as follows:

The specific code is as follows:

nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<title></title>
<style>
*{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></script>
<script>
$(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>


<p>
 </p><p>
  <input>
  </p>
       
  • 热门
  •    
  • A~G
  •    
  • H~L
  •    
  • M~T
  •    
  • W~Z
  •   
   

  

   
    北京     上海     广州     深圳     杭州     南京     成都     重庆    
  
  
   
A
   
    安宁     安康     安顺     安阳     安庆     鞍山    
   
B
   
    毕节     霸州     巴中     白山     保山     百色     巴彦淖尔     白银     亳州     北海     本溪     蚌埠     保定     滨州     包头     宝鸡     北京    
   
C
   
    从化     长葛     赤壁     承德     昌吉     池州     巢湖     长治     赤峰     潮州     滁州     沧州     常熟     郴州     常德     常州     长春     长沙     楚雄     慈溪     成都     重庆    
   
D
   
    敦煌     大丰     都匀     东阳     东港     迪庆     丹江口     大石桥     丹阳     定西     都江堰     达州     大同     大庆     丹东     德州     德阳     东营     大理     大连     东莞    
   
E
   
    鄂尔多斯     鄂州     恩施    
   
F
   
    福建     福清     阜阳     抚州     防城港     阜新     抚顺     富阳     佛山     福州    
   
G
   
    盖州     固原     高邮     广汉     贵港     赣州     贵阳     桂林     广州    
  
  
   
H
   
    华蓥     侯马     鹤山     洪湖     怀化     淮北     衡水     河池     鹤岗     海门     鹤壁     海安     黄冈     汉中     贺州     呼伦贝尔     黄石     河源     黄山     淮南     邯郸     淮安     海口     葫芦岛     菏泽     衡阳     合肥     湖州     哈尔滨     红河     惠州     呼和浩特     杭州    
   
J
   
    晋江     吉林     金坛     即墨     吉安     晋中     句容     酒泉     胶州     嘉峪关     鸡西     荆门     荆州     济源     锦州     焦作     揭阳     江阴     景德镇     晋城     江门     济南     佳木斯     济宁     九江     靖江     建德     金华     嘉兴    
   
K
   
    喀什     凯里     开平     开封     昆山     昆明    
   
L
   
    利川     乐平     临清     龙口     龙泉     吕梁     拉萨     丽江     临沧     陇南     漯河     辽阳     莱阳     临海     六盘水     耒阳     辽源     六安     临安     溧阳     泸州     龙岩     丽水     连云港     临沂     柳州     莱芜     聊城     乐山     临汾     洛阳     廊坊     娄底     兰州    
  
  
   
M
   
    麻城     眉山     梅州     茂名     牡丹江     绵阳     马鞍山    
   
N
   
    宁国     南平     宁德     内江     南充     南阳     南昌     南京     南宁     宁波     南通    
   
P
   
    普洱     邳州     平凉     攀枝花     萍乡     盘锦     濮阳     平顶山     莆田    
   
Q
   
    青州     琼海     曲靖     潜江     钦州     迁安     启东     齐齐哈尔     秦皇岛     泉州     清远     青岛     衢州    
   
R
   
    仁怀     如皋     日照     瑞安    
   
S
   
    什邡     尚志     寿光     三河市     韶山     上虞     宿州     汕尾     商洛     射阳     绥化     随州     三门峡     石嘴山     四平     遂宁     石河子     松原     上饶     韶关     三亚     十堰     商丘     宿迁     汕头     邵阳     三明     绍兴     苏州     石家庄     深圳     沈阳     上海    
   
T
   
    泰兴     铜仁     通辽     铜川     铁岭     天门     通化     天水     滕州     铜陵     桐乡     泰安     泰州     台州     唐山     太原     天津    
  
  
   
W
   
    乌兰浩特     乌海     武威     渭南     乌鲁木齐     芜湖     温州     吴江     潍坊     威海     无锡     梧州     武汉    
   
X
   
    西昌     兴城     湘西     西双版纳     仙桃     咸宁     许昌     孝感     宣城     新余     信阳     咸阳     西宁     湘潭     新乡     襄阳     邢台     厦门     徐州     西安    
   
Y
   
    兖州     余姚     义乌     玉林     云浮     鹰潭     扬中     玉溪     益阳     永州     延安     宜宾     宜春     延边     榆林     岳阳     宜兴     运城     银川     盐城     伊犁     营口     阳泉     宜昌     扬州     阳江     仪征     烟台    
   
Z
   
    邹城     中卫     张掖     张家界     诸城     资阳     遵义     舟山     张家口     张家港     漳州     枣庄     珠海     淄博     自贡     驻马店     株洲     肇庆     镇江     中山     郑州     湛江     周口    
  
 

I believe you have mastered the method after reading the case in this article, more Please pay attention to other related articles on the php Chinese website!

Recommended reading:

Detailed explanation of the use of tablesorter plug-in (with case)

jQuery implements tab sliding switching menu with slide effect

The above is the detailed content of jQuery realizes sliding switching between provinces and cities (with code). For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Python vs. JavaScript: Community, Libraries, and ResourcesPython vs. JavaScript: Community, Libraries, and ResourcesApr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

From C/C   to JavaScript: How It All WorksFrom C/C to JavaScript: How It All WorksApr 14, 2025 am 12:05 AM

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

JavaScript Engines: Comparing ImplementationsJavaScript Engines: Comparing ImplementationsApr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Beyond the Browser: JavaScript in the Real WorldBeyond the Browser: JavaScript in the Real WorldApr 12, 2025 am 12:06 AM

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Apr 11, 2025 am 08:23 AM

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)Apr 11, 2025 am 08:22 AM

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript: Exploring the Versatility of a Web LanguageJavaScript: Exploring the Versatility of a Web LanguageApr 11, 2025 am 12:01 AM

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The Evolution of JavaScript: Current Trends and Future ProspectsThe Evolution of JavaScript: Current Trends and Future ProspectsApr 10, 2025 am 09:33 AM

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software