The example in this article describes the fixedMenu drop-down menu effect code implemented by jQuery. Share it with everyone for your reference. The details are as follows:
Here is a demonstration of a Google-style drop-down menu. Its core is actually the jquery.fixedMenu menu, using jquery.fixedMenu.js and fixedMenu_style.css files. Comments have been added to the code. You can share it from this code. Extract these two files and reference them again. This menu can display the secondary submenu downwards when the mouse clicks on the main menu. In Firefox or Chrome browser, the menu shadow effect can also be displayed.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/jquery-fixedMenu-menu-style-codes/
The specific code is as follows:
<!DOCTYPE html> <head> <title>jQuery仿Google下拉导航菜单</title> <script type="text/javascript" src="jquery-1.6.2.min.js"></script> <style> /*fixedMenu_style.css代码*/ body{padding: 0;margin: 0;} .menu{font: 13px/27px Arial,sans-serif;color: #3366CC;height: 30px;background: url(images/back.gif) repeat-x;} .menu a: hover{background-color: #e4ebf8;} .menu a{text-decoration: none;padding: 4px 8px 7px;color: #3366CC;outline: none;} .menu ul{list-style: none;margin: 0;padding: 0 0 0 10px;} .menu ul li{padding: 0;float: left;} .menu ul li ul li{padding: 0;float: none;margin: 0 0 0 0px;width: 100%;} .menu ul li ul{position: absolute;border: 1px solid #C3D1EC;box-shadow: 0 1px 5px #CCCCCC;margin-top: -1px;display: none;padding: 0px 16px 0px 0;} .active ul{display: block !important;} .active a{background-color: white;border: 1px solid #C3D1EC;border-bottom: 0;box-shadow: 0 -1px 5px #CCCCCC;display: block;height: 29px;padding: 0 8px 0 8px;position: relative;z-index: 1;} .active a: hover{background-color: white;} .active ul a: hover{background-color: #e4ebf8;} .active ul a{border: 0 !important;box-shadow: 0 0 0 #CCCCCC;border: 0;width: 100%;} .arrow{border-color: #3366CC transparent transparent;border-style: solid dashed dashed;margin-left: 5px;position: relative;top: 10px;} </style> <script> //jquery.fixedMenu.js文件代码开始 (function($){ $.fn.fixedMenu=function(){ return this.each(function(){ var menu= $(this); menu.find('ul li > a').bind('click',function(){ if ($(this).parent().hasClass('active')){ $(this).parent().removeClass('active'); } else{ $(this).parent().parent().find('.active').removeClass('active'); $(this).parent().addClass('active'); } }) }); } })(jQuery); //jquery.fixedMenu.js文件代码结束 $('document').ready(function(){ $('.menu').fixedMenu(); }); </script> </head> <body> <div class="menu"> <ul> <li> <a href="#">More Examples<span class="arrow"></span></a> <ul> <li><a href="#">Plugins and jQuery Examples</a></li> <li><a href="#">Prototype Examples</a></li> <li><a href="#">Mootools Examples</a></li> <li><a href="#">Javascript Examples</a></li> </ul> </li> <li> <a href="#">Plugins<span class="arrow"></span></a> <ul> <li><a href="#">Galleries</a></li> <li><a href="#">DropDown Menus</a></li> <li><a href="#">Content Slider</a></li> <li><a href="#">LightBox</a></li> </ul> </li> <li> <a href="#">Friend Sites<span class="arrow"></span></a> <ul> <li><a href="#">关于我们</a></li> <li><a href="#">jquery特效</a></li> </ul> </li> <li> <a href="#">Contact<span class="arrow"></span></a> <ul> <li><a href="#">Follow us on Twitter</a></li> <li><a href="#">Facebook</a></li> <li><a href="#">Rss</a></li> <li><a href="#">e-mail</a></li> </ul> </li> </ul> </div> <div style="margin-top:200px;"> </body> </html>
I hope this article will be helpful to everyone’s jquery programming design.

实现方法:1、用“$("img").delay(毫秒数).fadeOut()”语句,delay()设置延迟秒数;2、用“setTimeout(function(){ $("img").hide(); },毫秒值);”语句,通过定时器来延迟。

修改方法:1、用css()设置新样式,语法“$(元素).css("min-height","新值")”;2、用attr(),通过设置style属性来添加新样式,语法“$(元素).attr("style","min-height:新值")”。

区别:1、axios是一个异步请求框架,用于封装底层的XMLHttpRequest,而jquery是一个JavaScript库,只是顺便封装了dom操作;2、axios是基于承诺对象的,可以用承诺对象中的方法,而jquery不基于承诺对象。

增加元素的方法:1、用append(),语法“$("body").append(新元素)”,可向body内部的末尾处增加元素;2、用prepend(),语法“$("body").prepend(新元素)”,可向body内部的开始处增加元素。

在jquery中,apply()方法用于改变this指向,使用另一个对象替换当前对象,是应用某一对象的一个方法,语法为“apply(thisobj,[argarray])”;参数argarray表示的是以数组的形式进行传递。

删除方法:1、用empty(),语法“$("div").empty();”,可删除所有子节点和内容;2、用children()和remove(),语法“$("div").children().remove();”,只删除子元素,不删除内容。

去掉方法:1、用“$(selector).removeAttr("readonly")”语句删除readonly属性;2、用“$(selector).attr("readonly",false)”将readonly属性的值设置为false。

on()方法有4个参数:1、第一个参数不可省略,规定要从被选元素添加的一个或多个事件或命名空间;2、第二个参数可省略,规定元素的事件处理程序;3、第三个参数可省略,规定传递到函数的额外数据;4、第四个参数可省略,规定当事件发生时运行的函数。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor
