


js realizes Jingdong's second-level menu effect (with delay function)_jquery
The example in this article describes how jquery can imitate the second-level menu effect of Jingdong. Share it with everyone for your reference. The details are as follows:
Here we introduce js code to imitate Jingdong level 2 menu effect, with delay function, making the operation more comfortable and natural.
Let’s take a look at the screenshots of the running effect:
The online demo address is as follows:
http://demo.jb51.net/js/2015/jquery-fjd-style-menu-codes/
The specific code 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>仿京东网站的2级菜单导航</title> <style type="text/css"> ul{margin:0;padding:0;list-style-type:none;} a{ text-decoration:none;} .mold_open_hover,.mold_open{background-image:url();background-repeat:none;display:inline-block;width:10px;height:6px;margin-left:10px;position:relative;top:-2px;} .mold_open{background-position:0 -6px;} .mold_open_hover{background-position:0 0;} .mod-menu{position:relative;z-index:1000;left:-1px;margin-left:100px;} h1{margin-left:100px;} .menu-cont-list a:hover{text-decoration:underline;} .mod-menu .menu-item{width:220px;border-top:solid 1px #d59bb2;border-bottom:solid 2px #d59bb2;position:relative;z-index:22;} .mod-menu .menu-item li{height:47px;line-height:47px;background:#feebf3;border-top:solid 1px #f0bfd3;} .mod-menu .menu-item li.mouse-bg{background:url() no-repeat #fff;position:relative;z-index:22;margin-right:-4px;} .mod-menu .menu-item a{color:#c81d61;font-size:16px;padding-left:33px;display:block;height:45px;border-top:solid 1px #f1f2f7;} .mod-menu .menu-item a:hover{ text-decoration:none;} .mod-menu .menu-cont{position:absolute;left:220px;top:1px;background:#fff;width:573px;border:solid 1px #F0BFD3;box-shadow:2px 0 10px rgba(210,33,103,0.25);z-index:20;} .mod-menu .menu-cont-list{padding:0 30px;} .mod-menu .menu-cont-list li{border-bottom:dotted 1px #f0bfd3;padding:10px 0;} .mod-menu .menu-cont-list li:last-child{border-bottom:none;} .mod-menu .menu-cont-list h3{font-size:14px;font-weight:700;} .mod-menu .menu-cont-list h3 a{color:#222;} .mod-menu .menu-list-link a{color:#666;line-height:24px;} .mod-menu .menu-list-link .long-string{color:#ccc;font-size:12px;padding:0 10px;} </style> <script src="jquery-1.6.2.min.js" type="text/javascript"></script> <script type="text/javascript"> var l; var t; var menuItem; $(document).ready(menu_init); function menu_init() { var mod_menu=$(".mod-menu");//导航模块区 menu();//执行展开二级菜单函 //setTimeout(menu(),1000) } var menu=function() { menuItem=$(".menu-item li");//选择导航列表 menuItem.each(menu_each);/*导航菜单菜单*/ menuItem.mouseleave(menu1_leave);/*导航菜单菜单*/ $(".mod-menu").mouseleave(menu2_mouse_leave); }//展开二级菜单 var menu_each=function() { var _index=$(this).index();//获取当前选择菜单列表的索引 $(this).mouseenter(menu_mouse_enter); } var menu_mouse_enter=function() { l = $(this);//获取当前鼠标滑过的列表的顶部坐标 t=setTimeout("menu_mouse_enter_show()", 300) } function menu_mouse_enter_show() { // alert(y1); var y = l.position().top+1;//获取当前鼠标滑过的列表的顶部坐标 $(".menu-cont").show(); $(".menu-cont").css("top",y);//需要显示的对应索引内容 l.addClass("mouse-bg").siblings().removeClass("mouse-bg"); $(".menu-cont>div").eq(_index).show().siblings().hide(); } var menu1_leave=function() { clearTimeout(t); } var menu2_mouse_leave=function() { $(".menu-cont").hide(); menuItem.removeClass("mouse-bg"); } </script> </head> <body> <h1 id="简单的-级菜单导航">简单的2级菜单导航</h1> <div class="mod-menu f-l"> <div id="column-left"> <ul class="menu-item"> <li class=""><a href="#">Wedding</a></li> <li class=""><a href="#">Women's Shoes</a></li> <li class=""><a href="#">Accessories</a></li> <li class=""><a href="#">Beauty & Health</a></li> </ul><!--一级菜单列表--> <div class="menu-cont hide" style="display: none; top: 241px;"> <div class="menu-cont-list" style="display: none;"> <ul> <li> <h3 id="a-href-Wedding-Dresses-a"><a href="#">Wedding Dresses</a></h3> <div class="menu-list-link"></div> </li> <li> <h3 id="a-href-Bridesmaid-Dresses-a"><a href="#">Bridesmaid Dresses</a></h3> <div class="menu-list-link"></div> </li> <li> <h3 id="a-href-Wedding-Party-Dresses-a"><a href="#">Wedding Party Dresses</a></h3> <div class="menu-list-link"> <a title="" href="#">Mother of the Brides Dresses</a> <span class="long-string">|</span> <a title="" href="#">Flower Girl Dresses</a> <span class="long-string">|</span> <a title="" href="#">Wedding Guest Dresses</a> </div> </li> <li> <h3 id="a-href-Wedding-Accessories-a"><a href="#">Wedding Accessories</a></h3> <div class="menu-list-link"> <a title="" #">Fabric Swatch</a> <span class="long-string">|</span> <a title="" href="#">Bridal Lingerie</a> <span class="long-string">|</span> <a title="" href="#">Wedding Flowers</a> <span class="long-string">|</span> <a title="" href="#">Wedding Petticoats</a> </div> </li> </ul> </div> <div class="menu-cont-list" style="display: none;"> <ul> <li> <h3 id="a-href-Prom-Dresses-a"><a href="#">Prom Dresses</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Military-Ball-Dresses-a"><a href="#">Military Ball Dresses</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Evening-Dresses-a"><a href="#">Evening Dresses</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Cocktail-Dresses-a"><a href="#">Cocktail Dresses</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Ball-Gowns-a"><a href="#">Ball Gowns</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Homecoming-Dresses-a"><a href="#">Homecoming Dresses</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Little-Black-Dresses-a"><a href="#">Little Black Dresses </a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Quinceanera-Dresses-a"><a href="#">Quinceanera Dresses</a></h3> <div class="menu-list-link"> </div> </li> </ul> </div> <div class="menu-cont-list" style="display: none;"> <ul> <li> <h3 id="a-href-Dresses-a"><a href="#">Dresses</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Clubwear-a"><a href="#">Clubwear</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Leggings-a"><a href="#">Leggings</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Lingeries-a"><a href="#">Lingeries</a></h3> <div class="menu-list-link"> <a title="" #">Bras</a> <span class="long-string">|</span> <a title="" href="#">Babydolls</a> <span class="long-string">|</span> <a title="" href="#">Panties</a> <span class="long-string">|</span> <a title="" href="#">Hosiery</a> </div> </li> <li> <h3 id="a-href-Swimwear-a"><a href="#">Swimwear</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Activewear-a"><a href="#">Activewear</a></h3> <div class="menu-list-link"> </div> </li> </ul> </div> <div class="menu-cont-list" style="display: none;"> <ul> <li> <h3 id="a-href-Heels-a"><a href="#">Heels</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Pumps-a"><a href="#">Pumps</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Boots-a"><a href="#">Boots</a></h3> <div class="menu-list-link"> </div> </li> </ul> </div> <div class="menu-cont-list" style="display: none;"> <ul> <li> <h3 id="a-href-Evening-Bags-a"><a href="#">Evening Bags</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Hats-Scarves-a"><a href="#">Hats & Scarves</a></h3> <div class="menu-list-link"> <a title="" href="#">Womens Hats</a> <span class="long-string">|</span> <a title="" href="#">Womens Scarves</a> </div> </li> <li> <h3 id="a-href-Jewelry-a"><a href="#">Jewelry</a></h3> <div class="menu-list-link"> <a title="" href="#">Earrings</a> <span class="long-string">|</span> <a title="" href="#">Necklaces</a> <span class="long-string">|</span> <a title="" href="#">Rings</a> </div> </li> <li> <h3 id="a-href-Watches-a"><a href="#">Watches</a></h3> <div class="menu-list-link"> </div> </li> </ul> </div> <div class="menu-cont-list" style="display: block;"> <ul> <li> <h3 id="a-href-Wigs-Hair-extensions-a"><a href="#">Wigs & Hair extensions</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Fascinators-a"><a href="#">Fascinators</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Makeup-Tools-a"><a href="#">Makeup Tools</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Spas-Massagers-a"><a href="#">Spas & Massagers</a></h3> <div class="menu-list-link"> </div> </li> <li> <h3 id="a-href-Health-Fitness-a"><a href="#">Health & Fitness</a></h3> <div class="menu-list-link"> </div> </li> </ul> </div> </div> </div><!--二级菜单内容--> </div> 若提示有错误,请刷新网页 </body> </html>
I hope this article will be helpful to everyone’s jquery programming design.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base


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

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

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!

Zend Studio 13.0.1
Powerful PHP integrated development environment