Published in: JavaScript
URL: http://jquery.com/
/**
* Slide menu with jQuery
*
* @package bitemibajtem.pl
* @copyright 2007-2008 (C) BITEM I BAJTEM
* @author Wojciech Sobczak (vbert)
* @access public
*/
<!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" lang="pl" xml:lang="pl"> <head> <title>Slide menu with jQuery</title> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="pl" /> <meta http-equiv="Pragma" content="no-cache" /> <meta name="Author" content="Wojciech Sobczak (vbert)" /> <style rel="stylesheet" type="text/css" media="screen"> html, body { margin: 0; padding: 0; border: 0 none; height: 100%; } div, span, ul, ol, dl, dt, dd { margin: 0; padding: 0; border: 0; } ul, ol, dl, dt, dd { list-style: none; } a, a:visited, a:hover { text-decoration: none; } a { color: #dcdc05; outline: none !important; } a:hover { color: #00c900; } legend { display: none; } body { background: #2e3436; color: #d3d6cf; font-size: 13px; } #container { margin: 100px auto; padding: 2px; width: 300px; border: 1px solid #666; text-align: center; } #menu { width: 300px; margin: 0 auto; text-align: left; } dt { margin-top: 2px; height: 34px; } dt a { display: block; height: 34px; padding-left: .35em; line-height: 34px; background: #222; font-family: Georgia, "Bookman Old Style", "Bookman Antiqua",serif; font-size: 1.5em; font-weight: bold; } dt.first { margin-top: 0; } #item-1 a, #sitem-1 a { color: #f9dc3f; } #item-2 a, #sitem-2 a { color: #8ff501; } #item-3 a, #sitem-3 a { color: #00c089; } #item-4 a, #sitem-4 a { color: #028eda; } #item-1 a:hover, #item-1 a.selected:hover, #sitem-1 a:hover, #sitem-1 a.selected:hover, #item-2 a:hover, #item-2 a.selected:hover, #sitem-1 a:hover, #sitem-1 a.selected:hover, #item-3 a:hover, #item-3 a.selected:hover, #sitem-3 a:hover, #sitem-3 a.selected:hover, #item-4 a:hover, #item-4 a.selected:hover, #sitem-4 a:hover, #sitem-4 a.selected:hover { color: #fff; } dt a:hover, dt a.selected:hover, dd a:hover, dd a.selected:hover { cursor: pointer; background: #3b98e2; } dd { margin-bottom: 2px; border-bottom: 1px solid #666; } dd.last { border-bottom: 0 none; } dd ul li { height: 24px; } dd ul li a { display: block; padding-left: 20px; height: 24px; line-height: 24px; background: transparent; font-family: "Lucida Grande", LucidaGrande, Geneva, Verdana, sans-serif; font-size: 1.1em; font-weight: bold; } </style> <script type="text/javascript" src="http://vbert.gildia.info/_proj/lib/jquery.pack.js"></script> <script type="text/javascript"> $(document).ready(function(){ if($("#menu")) { $("#menu dd").hide(); //:not(:first) $("#menu dt a").click(function() { if($(this).hasClass("selected")) { $(this).parent().next().slideUp(200); $(this).removeClass(); } else { $("#menu dt a").removeClass(); $(this).addClass("selected"); $("#menu dd:visible").slideUp(200); $(this).parent().next().slideDown(220); } return false; }); } }); </script> </head> <body> <!-- #container --> <div id="container"> <!-- #menu --> <div id="menu"> <dl> <dt id="item-1" class="first"> <a href="#">ITEM 1</a> </dt> <dd id="sitem-1"> <ul> <li><a href="#">item 1-1</a></li> <li><a href="#">item 1-2</a></li> <li><a href="#">item 1-3</a></li> <li><a href="#">item 1-4</a></li> </ul> </dd> <dt id="item-2"> <a href="#">ITEM 2</a> </dt> <dd id="sitem-2"> <ul> <li><a href="#">item 2-1</a></li> <li><a href="#">item 2-2</a></li> <li><a href="#">item 2-3</a></li> <li><a href="#">item 2-4</a></li> </ul> </dd> <dt id="item-3"> <a href="#">ITEM 3</a> </dt> <dd id="sitem-3"> <ul> <li><a href="#">item 3-1</a></li> <li><a href="#">item 3-2</a></li> <li><a href="#">item 3-3</a></li> <li><a href="#">item 3-4</a></li> </ul> </dd> <dt id="item-4"> <a href="#">ITEM 4</a> </dt> <dd id="sitem-4" class="last"> <ul> <li><a href="#">item 4-1</a></li> <li><a href="#">item 4-2</a></li> <li><a href="#">item 4-3</a></li> <li><a href="#">item 4-4</a></li> </ul> </dd> </dl> </div><!-- END #menu --> </div><!-- END #container --> </body> </html>
You need to login to post a comment.
