参照:Up and Down slider using JQuery
<!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" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="ja" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="imagetoolbar" content="no" /> <title>エフェクト操作:スライディング:slideToggle()の使用例 | jQuery</title> <link rel="stylesheet" type="text/css" href="/content/lib/global.css" /> <!-- JS --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $("#sub-panel").click(function(){ $("#top-panel").slideToggle(); var el = $("#shText"); var state = $("#shText").html(); state = (state == 'Hide' ? '<span id="shText">Show</span>' : '<span id="shText">Hide</span>'); el.replaceWith(state); }); }); </script> <!-- CSS --> <style type="text/css"> #top-panel { background:#e8f3c6; border-bottom:3px solid #a6c34e; padding:14px 20px; text-align:right; } #sub-panel { text-align:center; } #sub-panel a { width:150px; float:right; color:#fff; text-decoration:none; margin-right:30px; font-weight:bold; background:url("/content/img/ajax/sub-left.png") bottom left no-repeat #a6c34e; } #sub-panel a span { padding:6px; background:url("/content/img/ajax/sub-right.png") right bottom no-repeat; display:block; } #sub-panel strong { color:#000;} .face { border:solid 2px #a6c34e; margin-left:10px; float:right;} </style> <link rel="stylesheet" type="text/css" href="/common/css/example.css"></head> <body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1> <h3 class='h'>実行結果</h3> <div id="wrap"> <h1>エフェクト操作:スライディング:slideToggle()の使用例 | jQuery</h1> <h2>パネルのスライドアップ・ダウン</h2> <p>参照:<a href='http://www.thatagency.com/design-studio-blog/2009/02/up-and-down-slider-using-jquery/'>Up and Down slider using JQuery</a></p> <!-- CODE --> <div id="top-panel"> <img src="/content/img/banner/banner2.gif" width="88" height="31" class="face"/> <strong>PHP & JavaScript Room</strong><br> Visit my site: <a href="http://phpjavascriptroom.com/">site</a> </div> <div id="sub-panel"><a href="#" id="toggle"><span id="shText">Hide</span></a></div> <!-- / CODE --> </div> </body> </html>