为什么jQuery UI自动完成返回为禁用/“;关闭”;

Why is jQuery UI autocomplete returning as disabled/"off"?

本文关键字:关闭 返回 UI jQuery 为什么      更新时间:2024-01-23

我正在尝试启用jQuery UI的自动完成功能,但每次控制台元素时,都会显示它已禁用或"关闭"。它为什么要这么做?

HTML<input type="text" id="contactName">

JS

使用"启用"字符串

$("#contactName").autocomplete({
    source: searchableNames
}, "enable")

使用"on"字符串

$("#contactName").autocomplete({
    source: searchableNames
}, "on")

设置选项

$("#contactName").autocomplete({
    disabled: false,
    source: searchableNames
})

结果

<input type="text" id="contactName" class="ui-autocomplete-input" autocomplete="off">

有人能解释一下为什么它一直处于禁用状态,以及我如何修复它吗?谢谢

使用以下脚本重置自动完成属性:

$("#contactName").removeAttr("autocomplete").attr("autocomplete", "On");