How to use Checkbox inside Select Option

前端 未结 12 2251
夕颜
夕颜 2020-11-22 09:15

The client has given me a design which has a Select Option menu containing a checkbox together with the item name as individual items in the list. Is there anyway possible t

12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 09:58

    If you want to create multiple select dropdowns in the same page:

    .multiselect {
      width: 200px;
    }
    
    .selectBox {
      position: relative;
    }
    
    .selectBox select {
      width: 100%;
      font-weight: bold;
    }
    
    .overSelect {
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
    }
    
    #checkboxes {
      display: none;
      border: 1px #dadada solid;
    }
    
    #checkboxes label {
      display: block;
    }
    
    #checkboxes label:hover {
      background-color: #1e90ff;
    }
    

    Html:

     

    Using Jquery:

     function showCheckboxes(elethis) {
            if($(elethis).next('#checkboxes').is(':hidden')){
                $(elethis).next('#checkboxes').show();
                $('.selectBox').not(elethis).next('#checkboxes').hide();  
            }else{
                $(elethis).next('#checkboxes').hide();
                $('.selectBox').not(elethis).next('#checkboxes').hide();
            }
     }
    

提交回复
热议问题