我在应用程序(https://github.com/selectize/selectize.js)中使用selectize.js程序包,并且试图隐藏光标。

javascript - 在selectize.js中隐藏箭头图标-LMLPHP

贝娄是一个示例代码:



 $('#select-beast-single-disabled').selectize({
                    create: true,
                    sortField: {field: 'text'}
                });

<html>
<head>
<body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/js/standalone/selectize.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/css/selectize.css" />
        <div class="demo">
            <div class="control-group">
                <select id="select-beast-single-disabled" class="demo-default" placeholder="Select a person...">
                    <option value="">Select a person...</option>
                    <option value="1">Arnold</option>
                    <option value="2" selected>Nikola Tesla</option>
                </select>
            </div>

        </div>
</body>
</head>
</html>





有什么解决方法吗?先感谢您 !

最佳答案

我相信this解决了您的问题

因此,有两种可能性:



将选项maxItems设置为字符串“ 1”,以跳过在输入中插入不同的CSS类的条件。



像这样:



  $('#select-beast-single-disabled').selectize({
                    create: true,
                    sortField: {field: 'text'},
                    maxItems: '1'
                });

<html>
<head>
<body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/js/standalone/selectize.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/css/selectize.css" />
        <div class="demo">
            <div class="control-group">
                <select id="select-beast-single-disabled" class="demo-default" placeholder="Select a person...">
                    <option value="">Select a person...</option>
                    <option value="1">Arnold</option>
                    <option value="2" selected>Nikola Tesla</option>
                </select>
            </div>
        </div>
</body>
</head>
</html>







从CSS移除箭头。



像这样:



 $('#select-beast-single-disabled').selectize({
                    create: true,
                    sortField: {field: 'text'}
                });

<html>
<head>
<body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/js/standalone/selectize.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/css/selectize.css" />
        <div class="demo">
            <div class="control-group">
                <select id="select-beast-single-disabled" class="demo-default" placeholder="Select a person...">
                    <option value="">Select a person...</option>
                    <option value="1">Arnold</option>
                    <option value="2" selected>Nikola Tesla</option>
                </select>
            </div>
        </div>
  <style>
    .selectize-control.single .selectize-input:after{
      display:none;
    }
  </style>
</body>
</head>
</html>

关于javascript - 在selectize.js中隐藏箭头图标,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59459938/

10-10 14:13