检测jQuery UI自动完成

检测jQuery UI自动完成

问题描述:

如何检测输入框当前是否是jQuery UI自动完成?似乎没有本地方法,但我希望有这样简单的东西:

How can I detect whether or not an input box is currently a jQuery UI autocomplete? There doesn't seem to be a native method for this, but I'm hoping there is something simple like this:

if ($("#q").autocomplete)
{
  //Do something
}

然而,有条件的似乎总是返回true。

That conditional, however, seems to always return true.

if ($("#q").hasClass("ac_input")) {
    // do something
}

UPDATE

JQuery UI自动完成小部件中的类名现在是'ui autocomplete-input'以便代码为:

The class name in the JQuery UI autocomplete widget is now 'ui-autocomplete-input' so that code would be:

if ($("#q").hasClass("ui-autocomplete-input")) {
    // do something
}