<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>下拉菜单(无限级)</title> <style> *{ padding: 0; margin: 0; } li{ list-style-type: none; } body{ margin: 50px; } .hide{ display: none; } .menu{ cursor: pointer; } </style> </head> <body> <ul> <li class="menu" style="float: left;"> <span>一级菜单</span> <ul class="hide"> <li class="menu"> <span>二级菜单</span> <ul class="hide"> <li class="menu"> <span>三级菜单</span> <ul class="hide"> <li class="menu"> <span>四级菜单</span> <ul class="hide"> <li class="menu"><span>五级菜单</span></li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> <li class="menu" style="float: left;"> <span>一级菜单</span> <ul class="hide"> <li class="menu"> <span>二级菜单</span> <ul class="hide"> <li class="menu"> <span>三级菜单</span> <ul class="hide"> <li class="menu"> <span>四级菜单</span> <ul class="hide"> <li class="menu"><span>五级菜单</span></li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> </ul> <script src="jquery.js"></script> <script> $(function(){ var menu = $(‘.menu‘); menu.hover(function(){ $(this).children(‘ul‘).show(); },function(){ $(this).children(‘ul‘).hide(); }); }); </script> </body> </html>
?
效果图:
?
?
?
原文:http://onestopweb.iteye.com/blog/2287132