Home >Web Front-end >JS Tutorial >jQuery three-level drop-down list navigation menu code sharing_jquery

jQuery three-level drop-down list navigation menu code sharing_jquery

WBOY
WBOYOriginal
2016-05-16 15:42:431213browse

The example in this article describes the jQuery three-level drop-down list navigation menu. Share it with everyone for your reference. The details are as follows:
The jQuery three-level drop-down list navigation menu is based on jquery-1.8.3.min.js and can be infinitely classified. It can intelligently determine whether there is a lower-level menu. The mouse will display the lower-level menu after passing the last menu.
Operation effect diagram: ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

Tips: If the browser does not work properly, you can try switching the browsing mode.

The jQuery three-level drop-down list navigation menu code shared with you is as follows



<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery三级下拉列表导航菜单</title>

<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>

<style type="text/css">
*{margin: 0; padding: 0;}
body{ font-size: 12px; }
li{ list-style: none;}
ul.nav li{ width: 200px; text-align:center;}
ul.nav > li{ float: left; margin-right:10px;}
ul.nav li h3{height: 40px; line-height: 40px;}
ul.nav > li > h3{ background: #72a7ff;}
ul.nav > li > ul > li h3{ background: #ffd9d9;}
ul.nav > li h3:hover,.choice{ background: #ffc0c0!important;}
ul > li > ul{ display: none;}
ul > li.on > ul{ display: block;}
ul.nav li{ position: relative;}
ul.nav > li > ul > li ul{ position: absolute; top: 0; right: -200px;}
ul.nav span.sub{ position: absolute; display: block; right:10px; top: 0; width: 10px; height: 40px; background: url(images/arrows.png) no-repeat center center;}
</style>

<script type="text/javascript">
 $(document).ready(function() {
 $("ul.nav li").hover(function(){
  $(this).addClass("on");

 },
 function(){
  $(this).removeClass("on");

 })
 });

 $(document).ready(function() {
 $("ul.nav li").hover(function(){
  $(this).parent("ul").siblings("h3").addClass("choice");

 },
 function(){
  $(this).parent("ul").siblings("h3").removeClass("choice");
 })
 });

 $(document).ready(function() { 
  if ($("ul.nav li").find("ul") .html()!="") {
  $("ul.nav li").parent("ul").siblings("h3").append("<span class='sub'></span>");  
  }
 });
</script>


</head>
<body>
<ul class="nav">
 <li><h3>我的网站</h3>
 <ul>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3>
  <ul>
  <li><h3>4级分类</h3>
   <ul>
   <li><h3>5级分类</h3></li>
   <li><h3>5级分类</h3></li>
   <li><h3>5级分类</h3></li>
   <li><h3>5级分类</h3></li>
   </ul>
  </li>
  <li><h3>4级分类</h3></li>
  <li><h3>4级分类</h3></li>
  <li><h3>4级分类</h3></li>
  </ul>
  </li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 </ul>
 </li>
 <li><h3>我的网站</h3>
 <ul>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 </ul>
 </li>
 <li><h3>我的网站</h3>
 <ul>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 </ul>
 </li>
 <li><h3>我的网站</h3>
 <ul>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 <li><h3>2级分类</h3>
  <ul>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  <li><h3>3级分类</h3></li>
  </ul>
 </li>
 </ul>
 </li>
</ul>

</body>
</html>
The above is the jQuery three-level drop-down list navigation menu code shared with you. I hope you like it.

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