jq 下拉框

Posted chen527

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jq 下拉框相关的知识,希望对你有一定的参考价值。

    <div class="alls">
            <div class="item">
                <div class="all">
                    <span class="alla">选择</span>
                    <span>
                        <div class="coinbig-c2c-sanj"></div>                        
                    </span>
                </div>

                <div class="son">
                    <div class="son-input">
                        <img class="imgst" src="img/Group-2-copy.svg">
                        <input class="leftop" type="text">
                    </div>
                    <div class="son1">
                        <div class="as">00000000</div>
                        <div class="as">11111111</div>
                        <div class="as">22222222</div>
                        <div class="as">33333333</div>
                        <div class="as">44444444</div>
                        <div class="as">55555555</div>
                        <div class="as">66666666</div>
                    </div>
                </div>
            </div>

        </div>
<script>
            if($(‘.all‘).length > 0) 
                $(‘.all‘).on(‘click‘, function(e) 
                    var isShow = $(this).parents(‘.item‘).find(‘.son‘).is(‘:hidden‘);
                    isShow ? $(this).parents(‘.item‘).find(‘.son‘).slideDown(300) : $(this).parents(‘.item‘).find(‘.son‘).slideUp(300);
                    e.preventDefault();
                    e.stopPropagation();
                );
            
            if($(‘.as‘).length > 0) 
                $(‘.as‘).on(‘click‘, function() 
                    $(this).parents(‘.item‘).find(‘.alla‘).text($(this).text());
                    $(‘.son‘).slideUp(300);
                );
            
            $(".leftop").on(‘click‘, function(e) 
                e.preventDefault();
                e.stopPropagation();
            )
            $(".imgst").on(‘click‘, function(e) 
                e.preventDefault();
                e.stopPropagation();
            )
        </script>
    .all 
                width: 100%;
                height: 46px;
                display: block;
                position: relative;
                color: rgba(255,255,255,1);
            
            
    
            
            .item 
                width: 100%;
                height: 100%;
                background: #2b4071;
                line-height: 48px;
                border-left: 1px solid #2a404f;
                cursor: pointer;
                border: 1px solid #2f4a64;
                border-radius: 3px;
            
            
            .alla 
                margin-left: 10px;
                font-size: 18px;
                position: relative;
                font-size: 14px;
            
            
            .as 
                padding-left: 10px;
                font-size: 14px;
            
            
            .as:hover 
                background: #495689;
            
            
            .son 
                width: 100%;
                display: none;
                background-color: #15284c;
                position: absolute;
                top: 48px;
                z-index: 1;
            
            
            .item 
                position: relative;
            
            
            .coinbig-c2c-sanj 
                width: 0;
                height: 0;
                border-width: 7px;
                border-style: solid;
                border-color: #ffffff transparent transparent transparent;
                background: #2b4071;
                position: absolute;
                right: 9px;
                top: 20px;
            
            
    
            
            .zida 
                font-size: 18px;
            
            
            
            
            .sonall 
                width: 100%;
                top: 48px;
            
            
        
            
            .imgst 
                float: right;
                width: 16px;
                height: 16px;
                margin-top: 12px;
                margin-right: 10px;
            
            
            .leftop 
                float: left;
                width: 80%;
                height: 100%;
                border: none;
            
                background: #15284c;
                color: #FFFFFF;
                padding-left: 10px;
                box-sizing: border-box;
            
            
            .son-input 
                width: 90%;
                height: 40px;
                border: 1px solid #495d9a;
                margin: 10px auto;
            
            
            .son1     
                overflow-y: auto;
                max-height: 192px;
                color: #EEEFF7;
            
            
            .son1::-webkit-scrollbar 
                width: 3px;
                height: 0px;
            
        
            .son1::-webkit-scrollbar-button 
                background-color: #15284c;
                
            .son1::-webkit-scrollbar-track 
                background: #15284c;
            
            
            .son1::-webkit-scrollbar-thumb 
                background: #2a404f;
                border-radius: 10px;
            
            
            .son1::-webkit-scrollbar-corner 
                background: #2a404f;
                        
            .alls 
                width: 300px;
            

 

以上是关于jq 下拉框的主要内容,如果未能解决你的问题,请参考以下文章

jq自定义多选下拉列表框

jq 下拉框

带有 jQ​​uery 的 Rails 中的动态下拉(选择框)菜单不可逆

JS动态添加下拉框跟文本域

jq实现简单的二级联动下拉框

jq easyui 怎么获取到每一行的值 并且把下拉框选中的值也获取到。