这是我标记的HTML代码,但每当我加载页面时,都不会出现select标记。我相信我已经包含了所有必要的链接,当我从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>
&#13;
答案 0 :(得分:0)
您没有包含正确的CSS和Java脚本库 -
请检查下面的代码 - 它的工作正常,你可以添加多个,让用户选择多个值,你也可以包含一个搜索选项,如果有很长的选项列表,请尝试data-live-search-style = &#34; startsWith&#34;
请检查以下代码 -
<!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>