Making a JQuery button act as a dropdown

后端 未结 4 632
醉梦人生
醉梦人生 2021-02-09 17:20

Take this JQuery UI Button sample as a reference: http://jqueryui.com/demos/button/#splitbutton

Now, how would you implement that dropdown when click the small button? M

4条回答
  •  野的像风
    2021-02-09 18:07

    HTML:

    Choose your option...
    • One
    • Two
    • Three

    CSS:

    .arrow
    {
        background: none repeat scroll 0 0 #FFFFFF;
        border: 1px solid #CCCCCC;
        font-size: 0.8em;
        font-weight: bold;
        height: 26px;
        left: 208px;
        line-height: 26px;
        position: absolute;
        text-align: center;
        vertical-align: middle;
        width: 26px;
        z-index: 100;
    }
    
    .selectBox
    {
        border: 1px solid #1F1F1F;
        list-style-type: none;
        margin: 0;
        padding: 3px;
        position: absolute;
        width: 200px;
        display:none;
        top: 25px;
    }
    
    #container
    {
        position:relative
    }
    
    .toggler
    {
        overflow:visible;
    }
    
    .default
    {
        border: 1px solid #1f1f1f;
        width:200px;
        height:20px;
        padding:3px;
        position:absolute
    }
    
    .selectBox li:hover
    {
        background:#ffffd
    }
    

    JQUERY:

    $('.arrow').click(function() {
        $('.selectBox').slideToggle(200).css('borderTop', 'none');
        $('.selectBox li').click(function() {
            $('.mehidden').val($(this).text());
            $('.default').text($(this).text());
            $('.selectBox').slideUp(200);
        });
    });
    

提交回复
热议问题