选择的JQuery没有显示搜索框?

时间:2017-06-15 20:25:48

标签: javascript jquery html jquery-chosen

我有一个包含少量字段的表单,应该使用下拉列表。我在每个select标签上创建了一个类。此类用于在每个元素上应用选择。加载表单后,我没有收到任何错误,但选择不起作用。只有屏幕上显示的是:

选择图片:https://i.stack.imgur.com/TQEK5.png

这是我的代码:

<form name="frmDemo" id="frmDemo" method="POST" action="#" class="frmLayout">
    <fieldset>
    <legend>Demographic</legend>
        <div class="formItem">
            <label for="city" class="required">City:</label>
            <select name="city" id="city" class="chosen">
                <option value="">Choose City</option>
                <cfoutput query="getCity">
                    <option value="#cityNum#">#cityName#</option>
                </cfoutput>
            </select>
        </div>
        <div class="formItem">
            <p align="center"><input type="button" name="chSubmit" id="chSubmit" value="Submit"></p>
        </div>
    </fieldset>
</form>

这是JQuery:

$(document).ready(function() {
    $('.chosen').each(function(){
        $(this).chosen();
    });
});

1 个答案:

答案 0 :(得分:1)

如果您的参考设置不正确,请使用以下内容:

加载CSS -> jQuery -> chosen

<link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.7.0/chosen.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.7.0/chosen.jquery.min.js"></script>

&#13;
&#13;
$(document).ready(function() {
  $('.chosen').each(function() {
    $(this).chosen();
  });
});
&#13;
<link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.7.0/chosen.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.7.0/chosen.jquery.min.js"></script>

<form name="frmDemo" id="frmDemo" method="POST" action="#" class="frmLayout">
  <fieldset>
    <legend>Demographic</legend>
    <div class="formItem">
      <label for="city" class="required">City:</label>
      <select name="city" id="city" class="chosen">
        <option value="">Choose City</option>
        <cfoutput query="getCity">
          <option value="#cityNum#">#cityName#</option>
        </cfoutput>
      </select>
    </div>
    <div class="formItem">
      <p align="center">
        <input type="button" name="chSubmit" id="chSubmit" value="Submit">
      </p>
    </div>
  </fieldset>
</form>
&#13;
&#13;
&#13;