在演示中使用jQuery Autocomplete组合框
http://jqueryui.com/demos/autocomplete/#combobox
如何使用jQuery重置可见的用户输入文本?
(在用户输入一些文本后,进行了自动完成选择并导致了一个不相关的更改)
注意:更改基础选择元素不会导致自动完成输入字段发生任何更改.
注意2:这是相关页面上的许多自动完成组合框之一(与演示不同)
我可以使用以下代码重置演示.需要注意的一点是隐藏了选择框,但需要维护这些值.
//clear each option if its selected
$('#combobox option').each(function() {
$(this).removeAttr('selected')
});
//set the first option as selected
$('#combobox option:first').attr('selected', 'selected');
//set the text of the input field to the text of the first option
$('input.ui-autocomplete-input').val($('#combobox option:first').text());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4949 次 |
| 最近记录: |