首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jquery nice select插件无法正常工作

问Jquery nice select插件无法正常工作
EN

Stack Overflow用户
提问于 2019-11-01 04:41:51
回答 1查看 1.3K关注 0票数 1

我已经下载了jquery nice select并将插件包含到我的项目中,文件的路径都是正确的。我也已经包含了jquery。我有一个问题,我的选择下拉列表显示正确。当我使用这段代码时

代码语言:javascript
复制
<script>
  $(document).ready(function() {
    $('select').niceSelect();
  });
</script>

<select>
  <option>first</option>
  <option>second</option>
  <option>third</option>
</select>

它在我的页面中显示select下拉列表,就像这样,甚至在选择元素被单击之前

代码语言:javascript
复制
first
second
third

它周围没有额外的样式或功能,它只显示选项标签。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-01 05:26:30

您的代码中没有错误。也不够清楚。取一份员工样本。

还要确保包含在JavaScript和CSS库的顶部。

​

代码语言:javascript
复制
$(document).ready(function() {
  $('select').niceSelect();
});
代码语言:javascript
复制
// CSS included from http://hernansartorio.com/jquery-nice-select
.container {
  margin-top: 48px;
}

.header {
  margin-bottom: 36px;
}
代码语言:javascript
复制
<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>

​

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58650907

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档