检测jQuery UI自动完成 [英] Detecting jQuery UI autocomplete

查看:89
本文介绍了检测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
}

这篇关于检测jQuery UI自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆