jQuery implements a secondary drop down navigation method that drives the drawing effect

  • 2020-05-12 02:13:54
  • OfStack

The example of this paper describes the jQuery implementation of the drawing effect of the level 2 drop-down navigation method. Share with you for your reference. The specific implementation method is as follows:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery2 Step guide menu </title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.effects.core.min.js"></script>
<style type="text/css">
body{ font-size:12px; font-family:Arial, Helvetica, sans-serif; margin:0; padding:10px;}
.nav_list{ list-style:none; margin:0; padding:0;}
.nav_list li{ float:left; text-align:center;  margin-right:10px; position:relative;}
.nav_list li a{ width:80px; text-align:center; padding:4px 0; text-decoration:none;color:#ccc; background:#996666; display:block; float:left;}
.nav_list li a.current{ width:80px; text-align:center; padding:4px 0; text-decoration:none;color:#fff; background:#f00; display:block; float:left;}
.nav_list li div.second{ color:#999999; height:0px; overflow:hidden; position:absolute; left:0; top:22px; width:80px;}
.nav_list li div.second a{ background:#666666; color:#fff;  border:none; width:80px; border-top:1px solid
#FFFFFF; padding:5px 0;}
</style>
<script type="text/javascript">
$(function(){ 
  Menu(".nav_list");
});
function Menu(ul_class_name){  
  Second(".nav_list");
  var li_name = ul_class_name+" "+"li";
  $("div.second").css("opacity","0.1");
  $(li_name).hover(
    function(){
      var a_height =  $(this).children("div.second a:first").css("height");
      var a_count = $(this).children("div.second").children("a").length;
      var slide_hieght =  (parseInt(a_height)+11)*a_count;
      $(this).children("div.second").stop().animate({height:slide_hieght+"px",opacity:"0.9"},600);  
      $(this).children("a:not(.current)").stop().animate({backgroundColor:"#f00",color:"#fff"},800);
    },function(){
      $(this).children("div.second").stop().animate({height:"0px",opacity:"0.1"},600);
      $(this).children("a:not(.current)").stop().animate({backgroundColor:"#996666",color:"#ccc"},800);
    });
}
function Second(ul_class_name){
  var second_menu = ul_class_name+" "+"li"+" "+"div.second"+" "+">"+" "+"a";
  $(second_menu).hover(
   function(){
      $(this).stop().animate({backgroundColor:"#000",opacity:"1"},400);
    },function(){
      $(this).stop().animate({backgroundColor:"#666",opacity:"0.9"},400);
    });
}
</script>
</head>
<body>
<ul class="nav_list">
  <li>
    <a href="#" class="current">Test_1</a>
    <div class="second">
      <a href="#">menu_1</a>
      <a href="#">menu_1</a>
      <a href="#">menu_1</a>
    </div>
  <li>
  <li>
    <a href="#">Test_2</a>
    <div class="second">
      <a href="#">menu_1</a>
      <a href="#">menu_1</a>
      <a href="#">menu_1</a>
      <a href="#">menu_1</a>
      <a href="#">menu_1</a>
      <a href="#">menu_1</a>
      <a href="#">menu_1</a>
      <a href="#">menu_1</a>
    </div>
  <li>
  <li>
    <a href="#">Test_3</a>
    <div class="second">
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
      <a href="#">menu_3</a>
    </div>
  <li>
  <li>
    <a href="#">Test_4</a>
    <div class="second">
      <a href="#">menu_4</a>
      <a href="#">menu_4</a>
      <a href="#">menu_4</a>
    </div>
  <li>
  <li>
    <a href="#">Test_5</a>
    <div class="second">
      <a href="#">menu_5</a>
      <a href="#">menu_5</a>
      <a href="#">menu_5</a>
    </div>
  <li>
</ul>
<div style="width:800px; clear:both; padding:10px;">
  <p> This is a 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 This is the text 1 paragraph </p>
</div>
</body>
</html>

I hope this article has been helpful to your jQuery programming.


Related articles: