Home > php教程 > PHP开发 > body text

A super simple drop-down menu implemented with jquery

高洛峰
Release: 2016-12-15 16:01:21
Original
1240 people have browsed it

A super simple drop-down menu implemented with jquery.

Rendering

Initial effect

A super simple drop-down menu implemented with jquery

Mouse hover effect

A super simple drop-down menu implemented with jquery

Code

<!DOCTYPE html> 
<html> 
<head> 
<script type="text/javascript" src="jquery-1.11.1.js"></script> 
<style> 

nav a { 
text-decoration: none; 
} 
nav > ul > li { 
float: left; 
text-align: center; 
padding: 0 0.5em; 
} 

nav li ul.sub-menu { 
display: none; 
padding-left: 0 !important; 
} 

.sub-menu li { 
color: white; 
} 

.sub-menu li:hover { 
background-color: black; 
} 

.sub-menu li:hover a { 
color: white; 
} 

ul { 
list-style: none; 
} 
</style> 
</head> 
<body> 
<nav> 
<ul> 
<li><a href="#">Home 
<ul class="sub-menu"> 
<li><a href="#">sub1</a></li> 
<li><a href="#">sub2</a></li> 
<li><a href="#">sub3</a></li> 
</ul> 
</li> 
<li><a href="#">Programming 
<ul class="sub-menu"> 
<li><a href="#">sub1</a></li> 
<li><a href="#">sub2</a></li> 
<li><a href="#">sub3</a></li> 
</ul> 
</li> 
<li><a href="#">Japanese 
<ul class="sub-menu"> 
<li><a href="#">sub1</a></li> 
<li><a href="#">sub2</a></li> 
<li><a href="#">sub3</a></li> 
</ul> 
</li> 
</ul> 
</nav> 
</body> 
<script type="text/javascript"> 
$(document).ready(function() { 
$(&#39;nav li&#39;).hover(function() { 
$(this).find(&#39;.sub-menu&#39;).css(&#39;display&#39;, &#39;block&#39;); 
}, function() { 
$(this).find(&#39;.sub-menu&#39;).css(&#39;display&#39;, &#39;none&#39;); 
}); 
}); 
</script> 
</html>
Copy after login


For more related articles about a super simple drop-down menu implemented with jquery, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!