如何使用jquery combobox拥有不同的最小长度

How to have different minlengths with jquery combobox?

本文关键字:何使用 jquery combobox 拥有      更新时间:2023-09-26

我在html中有2个html选择菜单。

我有jqueryui把它做成一个组合框。

如何将一个设置为与插件中设置的默认值不同的最小长度?

您可以使用不同的选择器分别定位它们,并使用不同的minLength运行.combobox()

例如,如果您有以下 HTML:

<select id="first">
  <!-- options... -->
</select>
<select id="second">
  <!-- options... -->
</select>

您可以执行以下操作:

$('#first').combobox();  /* first combo box, default minLength */
$('#second').combobox({ minLength: 4 });  /* second , different minLength */

您还可以在调用combobox()后更改选项。例如:

$('select').combobox();  /* convert all select menus to combobox */
$('#second').combobox("option", "minLength", 0); /* diff minLength for #second */