Making a drop-down menu with Css+jquery

Source: Internet
Author: User

Html

<p id= "Select_box" >    <dl id= "Types" >        <dt><span id= "Select_type" > Please select </span> </dt>        <dd> Department Stores </dd>        <dd> daily necessities </dd>        <dd> computer Peripherals </dd>        <DD > Digital Products </dd>    </dl></p>

Css

a{        Text-decoration:none;} #select_box {        position:relative;        top:10px;        left:0px;        Display:inline-block;        width:192px;} #select_box dl{        float:left;        width:192px;        height:32px;        Background: #FFFFFF;        Cursor:pointer;        z-index:100;} #select_box DL dt{        width:172px;        height:32px;        line-height:34px;        Font-size:1em;        Color: #fff;        Background:url (.. /img/select_bg.png) No-repeat center right;        Background-color:rgb (60,179,113);        margin:0;        padding-left:20px;} #select_box DL dd{        position:relative;        Left: -40px;        width:172px;        height:32px;        line-height:32px;        Font-size:. 9em;        Color: #FFFFFF;        Background: #2A8F57;        padding-left:20px;        Z-index:10;}

Jquery

$ (function () {                $ ("#types dd"). Hide ();                $ ("#select_box"). Toggle (function () {                    $ ("#types DD"). Stop (True,false). Slidedown ($);                },function () {                    $ ("#types DD"). Stop (True,false). Slideup ();                });                $ ("#types DD"). Click (function () {                    var type_val=$ (this). html ();                    $ ("#types DT"). HTML (type_val);                    $ ("#types DD"). Stop (True,false). Slideup ();})            

If you are using as a Select component, you can add form forms and hidden fields (type= "hidden"), use jquery to control write values to input, or control form form submissions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.