Bootstrap选择选择器问题

时间:2017-07-25 05:03:22

标签: javascript jquery html bootstrap-selectpicker

我想让我的Multi-Select看起来像我在这里找到的一个例子:https://silviomoreto.github.io/bootstrap-select/examples/。我从这里下载了SelectPicker.js:http://silviomoreto.github.io/bootstrap-select/。它并排显示2个盒子,我不能让普通的盒子消失。

<html>
    <head>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    </head>
    <body class="container">
        <br/><br/><br/><br/><br/>
        <div class="container-fluid">
            <div class="form-group">
              <select class="selectpicker" id="rating" multiple data-selected-text-format="count > 3">
                <option>G</option>
                <option>PG</option>
                <option>PG-13</option>
                <option>R</option>
                <option>NC-17</option>
              </select>
            </div>
        </div>
        <hr/>
        <button onclick=doThis();>SUBMIT</button>    
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script src="../Documents/Movies_New/movies_ui/bootstrap/js/bootstrap-select.js"></script>
        <script type="text/javascript">
        $(document).ready(function() {
            $('.selectpicker').selectpicker();

            function doThis(){
                alert('Submit');
            }
        });
        </script>
    </body>
</html>

Select Picker HTML Example Select Picker HTML Example2

2 个答案:

答案 0 :(得分:1)

我认为您缺少链接bootstrap-select.css。我在你的例子中使用它..

<html>
    <head>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">

<!-- Latest compiled and minified JavaScript -->
    </head>
    <body class="container">
        <br/><br/><br/><br/><br/>
        <div class="container-fluid">
            <div class="form-group">
              <select class="selectpicker" id="rating" multiple data-selected-text-format="count > 3">
                <option>G</option>
                <option>PG</option>
                <option>PG-13</option>
                <option>R</option>
                <option>NC-17</option>
              </select>
            </div>
        </div>
        <hr/>
        <button onclick=doThis();>SUBMIT</button>    
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>

        <script type="text/javascript">
        $(document).ready(function() {
            $('.selectpicker').selectpicker();

            function doThis(){
                alert('Submit');
            }
        });
        </script>
    </body>
</html>

答案 1 :(得分:0)

我想你错过了&#39; bootsrap-select&#39;。

的css

尝试这个。

<html>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <!-- Latest compiled and minified CSS -->
            <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">

</head>
<body class="container">
    <br/><br/><br/><br/><br/>
    <div class="container-fluid">
        <div class="form-group">
          <select class="selectpicker" id="rating" multiple data-selected-text-format="count > 3">
            <option>G</option>
            <option>PG</option>
            <option>PG-13</option>
            <option>R</option>
            <option>NC-17</option>
          </select>
        </div>
    </div>
    <hr/>
    <button onclick=doThis();>SUBMIT</button>    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!-- Latest compiled and minified JavaScript -->
            <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
        $('.selectpicker').selectpicker();

        function doThis(){
            alert('Submit');
        }
    });
    </script>
</body>