如果我的网页中有两个列表框,但我需要一个列表框为多选,另一个应该为通用列表框

If I have two listboxes in my webpage, but i need one listbox to be Multiselect the other should be general listbox

本文关键字:列表 一个 另一个 网页 我的 两个 如果      更新时间:2023-09-26

我正在使用http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/多选插件。默认情况下,这个插件会自动将普通的html选择框变成多选框,有什么方法可以让我在同一页面上使用这个多选插件和普通的html选项框吗?

提前一包感谢信。Jay

将选项multiple设置为false。或者不要调用$('select').multiselect

添加一个类

<select class="multiple-select"></select>

然后将选择器更改为:$('.multiple-select').multiselect,并将常规选择保留为不包含类。

示例

您可以将它与一些id$("select#multiple")一起使用,这样所有的选择框都不会用该插件呈现。

$("select#multiple").multiselect({
   header: "Select an option",
   noneSelectedText: "Select an Option",
   selectedList: 1
});

初始化时,执行以下操作:

$(function(){
    $("#mymulti").multiselect();
});
<select id="mymulti" name="example" multiple="multiple">
    <option value="1">Option 1</option>
    <option value="2">Option 2</option>
    <option value="3">Option 3</option>
    <option value="4">Option 4</option>
   <option value="5">Option 5</option>
</select>

此:

$("#mymulti").multiselect();

将仅适用于id为mymulti-

的select
相关文章: