コーヒーアンドキーボード

コーヒーとキーボードにまみれて生活してます。一応専門はデジタルマーケ。

jQueryを使ってドロップダウンメニューをシンプルに書いてみる

// jQuery読み込み
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1.7");</script>

// マウスオンとアウトでliの子要素であるulを表示したり消したり
$(function() {
    $("#menu li").hover(function() {
        $(this).children('ul').show();
    }, function() {
        $(this).children('ul').hide();
    });
});
  • コピペですがうまくいきました。