0

这是我标记的 HTML 代码,但每当我加载页面时,选择标签都不会出现。我相信我已经包含了所有必要的链接,当我从 select 标记中删除 .selectpicker 类时,它会正常显示,所以我一定错过了为什么它没有出现。谢谢!

<!doctype html>

<html lang="en">

<head>


    <meta charset="utf-8">

    <title>Test</title>
    <meta name="description" content="The HTML5 Herald">
    <meta name="author" content="SitePoint">

    <link rel="stylesheet" href="css/styles.css?v=1.0">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css">

    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/i18n/defaults-*.min.js"></script>



    <!--[if lt IE 9]>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
  <![endif]-->
</head>

<body>
    <select class="selectpicker" style="btn-info">
        <option>Mustard</option>
        <option>Ketchup</option>
        <option>Relish</option>
    </select>

    <script>
        $('.selectpicker').selectpicker({
            style: 'btn-info',
            size: 4
        });

    </script>
</body>

</html>

4

1 回答 1

0

您没有包含正确的 CSS 和 java 脚本库-

请检查下面的代码 - 它工作正常,您可以添加多个,让用户选择多个值,您还可以包含搜索选项,如果选项列表很长,请尝试 data-live-search-style="startsWith" .

请检查下面的代码 -

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Test</title>
    <meta name="description" content="The HTML5 Herald">
    <meta name="author" content="SitePoint">
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.1/css/bootstrap-select.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/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.1/js/bootstrap-select.js"></script>

</head>

<body>

<select class="selectpicker" multiple style="btn-info">
    <option>Mustard</option>
    <option>Ketchup</option>
    <option>Relish</option>
</select>

于 2017-07-10T12:34:48.210 回答