简体   繁体   English

bootstrap select仅显示链接单击时的下拉菜单,没有选择按钮

[英]bootstrap select show only dropdown-menu on link click without the select button

I have a link: 我有一个链接:

<a href="#" id="link">Click me</a>

when someone clicks the link I would like to show only the dropdown-menu like: 当有人单击链接时,我只想显示下拉菜单,例如:

在此处输入图片说明

how to remove the button? 如何删除按钮?

在此处输入图片说明

JSFIDDLE JSFIDDLE

HTML: HTML:

<a href="#" id="link">Click me</a>

<div id="searchSelect">                     
    <select name="searchName" id="idSelect" data-live-search="true" data-size="10">
        <option value="">ALL</option>
        <option value="Tom">Tom</option>
        <option value="John">John</option>
        <option value="Janet">Janet</option>
    </select>
</div>  

CSS: CSS:

#searchSelect 
{
  z-index:999; 
  position:absolute; 
  display:none;
}

JS: JS:

$("#idSelect").selectpicker();
$("#link").click(function(e) {
    e.preventDefault();
    $("#searchSelect").show();
});

$("#idSelect").change(function() {
    $("#searchSelect").hide();
});

I updated my answer and I think this is what you are looking for. 我更新了答案,我认为这就是您想要的。 just update your CSS. 只需更新您的CSS。

https://jsfiddle.net/n1zz8kkw/2/ https://jsfiddle.net/n1zz8kkw/2/

     #searchSelect {
      z-index: 999;
      position: absolute;
    }

    .bootstrap-select.btn-group .dropdown-toggle,
    .bootstrap-select.btn-group .dropdown-toggle:hover,
    .bootstrap-select.btn-group .dropdown-toggle:active,
    .bootstrap-select.btn-group .dropdown-toggle:focus {
      background: none !important;
      border: none !important;
      outline: 0px;
      box-shadow: none;
    }

    .bootstrap-select.btn-group .caret {
      display: none;
    }

    #searchSelect .btn.dropdown-toggle {
      height: 0px;
      padding: 0px;
    }

    .bootstrap-select.btn-group .filter-option {
      display: none !important;
    }

Good Luck 祝好运

If you mean the dropdown arrow, for Chrome you can use something like: 如果您的意思是下拉箭头,那么对于Chrome浏览器,您可以使用类似以下命令的内容:

<select style="-webkit-appearance: none;">

For more, see this question: Select removing dropdown arrow . 有关更多信息,请参见以下问题: 选择删除下拉箭头

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM