I recently discovered a simple jQuery drop-down menu with very little code, which is very suitable for beginners with basic knowledge to learn and improve.
This is the jQuery code:
<script type="text/javascript"> $(document).ready(function(){ $("ul.subnav").parent().append("<span></span>"); $("ul.topnav li span").click(function() { $(this).parent().find("ul.subnav").slideDown('fast'); $(this).parent().hover(function() { }, function(){ $(this).parent().find("ul.subnav").slideUp('slow'); }); }).hover(function() { $(this).addClass("subhover"); }, function(){ //On Hover Out $(this).removeClass("subhover"); }); }); </script>
The following is the html code:
<div id="header"> <ul class="topnav"> <li><a href="#">首页</a></li> <li> <a href="#">原创作品</a> <ul class="subnav"> <li><a href="#">绘画艺术</a></li> <li><a href="#">平面设计</a></li> <li><a href="#">交互设计</a></li> <li><a href="#">3D艺术</a></li> <li><a href="#">摄影艺术</a></li> <li><a href="#">其他艺术</a></li> </ul> </li> <li> <a href="#">设计素材</a> <ul class="subnav"> <li><a href="#">Sub Nav Link</a></li> <li><a href="#">Sub Nav Link</a></li> <li><a href="#">Sub Nav Link</a></li> <li><a href="#">Sub Nav Link</a></li> <li><a href="#">Sub Nav Link</a></li> <li><a href="#">Sub Nav Link</a></li> </ul> </li> <li> <a href="#">佳作欣赏</a> <ul class="subnav"> <li><a href="#">Sub Nav Link</a></li> <li><a href="#">Sub Nav Link</a></li> <li><a href="#">Sub Nav Link</a></li> <li><a href="#">Sub Nav Link</a></li> <li><a href="#">Sub Nav Link</a></li> <li><a href="#">Sub Nav Link</a></li> </ul> </li> <li><a href="#">论坛</a></li> <li><a href="#">网址导航</a></li> </ul> </div>
More of a jQuery drop-down menu, the code is simple and suitable for novices to read. For related articles, please pay attention to the PHP Chinese website!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

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.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment