如何使用jquery在下拉列表中选择多选项

时间:2016-07-07 11:36:53

标签: javascript

 <div class="multiselect">
        <div class="selectBox" onclick="showCheckboxes('dLang')">
            <select>
                <option>Select an option</option>
            </select>
            <div class="overSelect"></div>
        </div>
        <div class="checkboxes" id="dLang" style="overflow-x: hidden;">

            <label for="three"><input type="checkbox" id="three"/>Czech</label>
            <label for="three"><input type="checkbox" id="three"/>Danish</label>
            <label for="three"><input type="checkbox" id="three"/>Dutch</label>
        </div>
    </div>

#这个代码工作正常但我想在这里添加滚动条。可以提供任何帮助吗?#

2 个答案:

答案 0 :(得分:0)

看一下这个片段。这是你需要的吗?

&#13;
&#13;
.multiSelect {
  height: 100px;
  overflow: scroll;
  overflow-x: hidden;
}
&#13;
<select class="multiSelect" multiple>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
</select>
&#13;
&#13;
&#13; (按住CTRL键选择多个元素)

答案 1 :(得分:0)

This is you should need to check : http://www.jqueryfaqs.com/Articles/Multiple-Select-MultiSelect-DropDownList-with-CheckBoxes-using-jQuery.aspx     

<script type="text/javascript">
        $(function () {
            $('[id*=your id name ]').multiselect({
                includeSelectAllOption: true
            });
        });
    </script>