当前位置:Gxlcms > JavaScript > jQuery做出菜单导航栏功能

jQuery做出菜单导航栏功能

时间:2021-07-01 10:21:17 帮助过:3人阅读

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <metacharset="UTF-8">
  5. <title></title>
  6. <style>
  7. *{
  8. padding: 0px;
  9. margin: 0px;
  10. }
  11. #top{width: auto;height: 30px;background: #eee;position: relative;}
  12. #top li{float: left;
  13. text-align: center;
  14. width: 80px;
  15. height:30px;
  16. line-height:30px;
  17. list-style: none;
  18. }
  19. /*设置位置*/
  20. .position{
  21. position: absolute;
  22. border: 1px solid #ccc;
  23. top:30px;
  24. padding: 3px;
  25. font-size: 15px;
  26. display: none;
  27. }
  28. .shoucang{width: auto;left: 10px;}
  29. .sell{width: auto;left: 70px;}
  30. .customer{width: auto;left: 180px;}
  31. .bg{background-color: #DDA0DD;cursor: pointer;}
  32. </style>
  33. <scripttype="text/javascript"src="js/jquery-1.8.3.js"></script>
  34. <script>
  35. $(function(){
  36. $(".li1").hover(function(){
  37. $(".shoucang").show();/*显示收藏的菜单内容*/
  38. $(".customer,.sell").hide();/*隐藏其他的菜单内容*/
  39. },function(){
  40. $(".shoucang").hide();/*鼠标离开,收藏的菜单内容隐藏*/
  41. });
  42. $(".li2").hover(function(){
  43. $(".sell").show();
  44. $(".customer,.shoucang").hide();
  45. },function(){
  46. $(".sell").hide();
  47. });
  48. $(".li3").hover(function(){
  49. $(".customer").show();
  50. $(".shoucang,.sell").hide();
  51. },function(){
  52. $(".customer").hide();
  53. });
  54. $("#top p").hover(function(){/*鼠标放置在p位置上,显示下拉菜单*/
  55. $(this).show();
  56. },function(){/*鼠标离开在p位置上,隐藏下拉菜单*/
  57. $(this).hide();
  58. });
  59. $(".sell p,.shoucang p,.customer p").bind("mouseover",function(){
  60. $(this).addClass("bg");
  61. });
  62. $(".sell p,.shoucang p,.customer p").bind("mouseout",function(){
  63. $(this).removeClass("bg");
  64. });
  65. });
  66. </script>
  67. </head>
  68. <body>
  69. <pid="top">
  70. <ul>
  71. <liclass="li1">收藏夹</li>
  72. <liclass="li2">卖家中心</li>
  73. <liclass="li3">联系客服</li>
  74. </ul>
  75. <pclass="shoucang position">
  76. <p>收藏的宝贝</p>
  77. <p>收藏的店铺</p>
  78. </p>
  79. <pclass="sell position">
  80. <p>免费开店</p>
  81. <p>已出售的报宝贝</p>
  82. <p>出售中的报宝贝</p>
  83. <p>卖家服务市场</p>
  84. </p>
  85. <pclass="customer position">
  86. <p>消费者客服</p>
  87. <p>卖家客服</p>
  88. </p>
  89. </p>
  90. </body>
  91. </html>

相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!

推荐阅读:

jQuery操作输入框统计字数

jQuery表格顶栏固定效果

jquery插件扩展使用详解

以上就是jQuery做出菜单导航栏功能的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行