在jQuery中使用CSS选择器数组 [英] Using an array of CSS selectors in jQuery
问题描述
我正在尝试使用jQuery自动完成插件.我有一个要插入的ID数组.所以,说我有:
I'm trying to use the jQuery autocomplete plugin. I have an array of IDs that I want to plugin to work on. So, say I have:
var aIds = ["1", "2"];
我看到的有关如何使用该插件的示例如下:
The examples I see on how to use the plugin looks like this:
$('#1').autocomplete
我是否可以使用此自动完成插件和ID数组? ID数组来自Web服务.
Is there a way for me to use this autocomplete plugin and my array of ids? The array of ids are coming from a web service.
此外,自动完成插件还会显示某些事件,例如select
(请参阅: http://docs.jquery.com/UI/Autocomplete#event-select ).发生这种情况时,如何确定哪个元素触发了事件(如果我要动态分配ID数组)?
Also, the autocomplete plugin exposes certain events like select
(see: http://docs.jquery.com/UI/Autocomplete#event-select). When that happens, how can I tell which element triggered the event (if I am assigning the array of ids dynamically)?
推荐答案
如果要创建选择器:
$('#' + aIds.join(', #')).autocomplete();
这篇关于在jQuery中使用CSS选择器数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!