jQuery实现的动态伸缩导航菜单实例
2019/6/29 22:27:36
本文主要是介绍jQuery实现的动态伸缩导航菜单实例,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
本文实例讲述了jQuery实现的动态伸缩导航菜单。分享给大家供大家参考。具体实现方法如下:
<!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>jquery select</title> <script type="text/javascript" src="jquery-1.6.2.min.js"></script> <style type="text/css"> body {padding:10px; font-family:"宋体"} * {margin:0; padding:0; font-size:12px;} a{ color: #333;} ul,li { list-style-type:none; } .menu_list li a { display:block; line-height:30px; text-align:center; height:30px; background:#e8e8e8; border-bottom:1px solid #ccc; } .hover { background:#e8e8e8; } .div1{ height:200px; display:none; padding:5px; } .menu_list{ width:200px; background:#f2f2f2; border:1px solid #ccc; } </style> <script type="text/javascript"> $(document).ready(function() { $(".menu_list ul li").click(function() { if($(this).children(".div1").is(":hidden")) //判断对象是显示还是隐藏 { if(!$(this).children(".div1").is(":animated")){ //如果当前没有进行动画,则添加新动画 $(this).children(".div1").animate({height:'show'},1000) .end().siblings().find(".div1").hide(1000);} }else{ if(!$(this).children(".div1").is(":animated")){ $(this).children(".div1").animate({height:'hide'},1000) .end().siblings().find(".div1").hide(1000);} } } ); }); </script> <div class="menu_list" id="secondpane"> <ul> <li class=""> <a href="javascript:void(0);" class="a1">网页特效</a> <div class="div1">js特效,网页特效</div> </li> <li class=""> <a href="javascript:void(0);" class="a1">网页模板</a> <div class="div1">网页模板下载</div> </li> <li class=""> <a href="javascript:void(0);" class="a1" style="border:none;">联系我们 </a> <div class="div1" style="border-top:1px solid #ccc;">关于找一找教程网</div> </li> </ul> </div> </body> </html>
希望本文所述对大家的jQuery程序设计有所帮助。
这篇关于jQuery实现的动态伸缩导航菜单实例的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-06jquery对css样式(jquery中的css方法)-icode9专业技术文章分享
- 2023-05-27JQuery的认识和安装
- 2023-01-06JQuery应用技巧:如何定义 HTML 模板并使用 JQuery 进行加载-icode9专业技术文章分享
- 2022-09-29复习-jQuery
- 2022-09-04Python3项目初始化10-->前端基础jquery、ajax,sweetalert--更新用户改造
- 2022-08-30day 27 jquery
- 2022-08-29jQuery筛选器,bootstrap
- 2022-08-20JQuery事件绑定
- 2022-08-20JQuery案例
- 2022-08-07关于jQuery的学习