jQuery點擊彈出下拉菜單

<title>導航——點擊彈出內容</title>
    <style type="text/css">
.navgation{margin:0;padding:0;list-style-type:none;position:relative;}
.navgation li {float:left;}
.navgation a{padding:3px 6px;background-color:orange;color:white;text-decoration:none;float:left;height:24px;}
.navgation a:hover {background-color:white;color:blue;text-decoration:underline;}
.navgation p{display:none;position:absolute;top:30px;}
</style>
    <script src="Jquery1.7.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".navgation input").each(function () {
                var this_p = $(".navgation p");
                var _inx = $(".navgation input").index(this);
                $(this).click(
                function () { this_p.eq(_inx).slideToggle(); },
                function () { this_p.eq(_inx).slideToggle(); }
           );
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <p>
        <ul class="navgation">
            <li><input type="button" id="button" value="鏈接1"/>
            <p>這裡放下拉內容1</p>
            </li>
            <li><input type="button" id="button1" value="鏈接2"/>
            <p>這裡放下拉內容2</p>
            </li>
            <li><input type="button" id="button2" value="鏈接3"/>
            <p>這裡放下拉內容3</p>
            </li>
            <li><input type="button" id="button3" value="鏈接4"/>
            <p>這裡放下拉內容4</p>
            </li>
            <li><input type="button" id="button4" value="鏈接5"/>
            <p>這裡放下拉內容5</p>
            </li>
        </ul>
    </p>
    </form>
</body>

發佈留言