我已经下载了jquery nice select并将插件包含到我的项目中,文件的路径都是正确的。我也已经包含了jquery。我有一个问题,我的选择下拉列表显示正确。当我使用这段代码时
<script>
$(document).ready(function() {
$('select').niceSelect();
});
</script>
<select>
<option>first</option>
<option>second</option>
<option>third</option>
</select>它在我的页面中显示select下拉列表,就像这样,甚至在选择元素被单击之前
first
second
third它周围没有额外的样式或功能,它只显示选项标签。
发布于 2019-11-01 05:26:30
您的代码中没有错误。也不够清楚。取一份员工样本。
还要确保包含在JavaScript和CSS库的顶部。
$(document).ready(function() {
$('select').niceSelect();
});// CSS included from http://hernansartorio.com/jquery-nice-select
.container {
margin-top: 48px;
}
.header {
margin-bottom: 36px;
}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://hernansartorio.com/jquery-nice-select/js/jquery.nice-select.min.js"></script>
<script src="https://hernansartorio.com/jquery-nice-select/js/fastclick.js"></script>
<link rel="stylesheet" type="text/css" href="https://hernansartorio.com/jquery-nice-select/css/style.css">
<div class="container">
<div class="header">
<h1>jQuery Nice Select</h1>
<p>A lightweight jQuery plugin that replaces native select elements with customizable dropdowns.</p>
<a href="http://hernansartorio.com/jquery-nice-select/" class="button">See full documentation & download</a>
</div>
<h2>Defualt example</h2>
<div class="box">
<select>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select>
</div>
<h2>Display text</h2>
<p>You can specify an alternate text for each option, which will be displayed on the dropdown when that option is selected.</p>
<div class="box">
<select>
<option data-display="Select">Nothing</option>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select>
</div>
<h2>Custom classes</h2>
<p>Every class you assign to a select element will be copied to the generated dropdown. That way you can customize different versions of it to your needs just by adding new CSS.</p>
<div class="box">
<label>Wide</label>
<select class="wide">
<option data-display="Select">Nothing</option>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select>
</div>
<div class="box">
<label class="right">Right</label>
<select class="right">
<option data-display="Select">Nothing</option>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select>
</div>
<div class="box">
<label>Small</label>
<select class="small">
<option data-display="Select">Nothing</option>
<option value="1">Some option</option>
<option value="2">Another option</option>
<option value="3">Potato</option>
</select>
</div>
<div class="footer">
<p></p>
<a href="http://hernansartorio.com/jquery-nice-select/" class="button">See full documentation & download</a>
<div class="credit">
Made by <a href="http://hernansartorio.com/">Hernán Sartorio</a>
</div>
</div>
</div>
https://stackoverflow.com/questions/58650907
复制相似问题